Refactor/actions (#2733)

* store, properties, manifest

* interfaces

* init and backups

* fix init and backups

* file models

* more versions

* dependencies

* config except dynamic types

* clean up config

* remove disabled from non-dynamic vaues

* actions

* standardize example code block formats

* wip: actions refactor

Co-authored-by: Jade <Blu-J@users.noreply.github.com>

* commit types

* fix types

* update types

* update action request type

* update apis

* add description to actionrequest

* clean up imports

* revert package json

* chore: Remove the recursive to the index

* chore: Remove the other thing I was testing

* flatten action requests

* update container runtime with new config paradigm

* new actions strategy

* seems to be working

* misc backend fixes

* fix fe bugs

* only show breakages if breakages

* only show success modal if result

* don't panic on failed removal

* hide config from actions page

* polyfill autoconfig

* use metadata strategy for actions instead of prev

* misc fixes

* chore: split the sdk into 2 libs (#2736)

* follow sideload progress (#2718)

* follow sideload progress

* small bugfix

* shareReplay with no refcount false

* don't wrap sideload progress in RPCResult

* dont present toast

---------

Co-authored-by: Aiden McClelland <me@drbonez.dev>

* chore: Add the initial of the creation of the two sdk

* chore: Add in the baseDist

* chore: Add in the baseDist

* chore: Get the web and the runtime-container running

* chore: Remove the empty file

* chore: Fix it so the container-runtime works

---------

Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com>
Co-authored-by: Aiden McClelland <me@drbonez.dev>

* misc fixes

* update todos

* minor clean up

* fix link script

* update node version in CI test

* fix node version syntax in ci build

* wip: fixing callbacks

* fix sdk makefile dependencies

* add support for const outside of main

* update apis

* don't panic!

* Chore: Capture weird case on rpc, and log that

* fix procedure id issue

* pass input value for dep auto config

* handle disabled and warning for actions

* chore: Fix for link not having node_modules

* sdk fixes

* fix build

* fix build

* fix build

---------

Co-authored-by: Matt Hill <mattnine@protonmail.com>
Co-authored-by: Jade <Blu-J@users.noreply.github.com>
Co-authored-by: J H <dragondef@gmail.com>
Co-authored-by: Jade <2364004+Blu-J@users.noreply.github.com>
Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com>
This commit is contained in:
Aiden McClelland
2024-09-25 16:12:52 -06:00
committed by GitHub
parent eec5cf6b65
commit db0695126f
469 changed files with 16218 additions and 10485 deletions

View File

@@ -7,7 +7,7 @@ import {
ValidatorFn,
Validators,
} from '@angular/forms'
import { CT, utils } from '@start9labs/start-sdk'
import { IST, utils } from '@start9labs/start-sdk'
const Mustache = require('mustache')
@Injectable({
@@ -17,16 +17,16 @@ export class FormService {
constructor(private readonly formBuilder: UntypedFormBuilder) {}
createForm(
spec: CT.InputSpec,
spec: IST.InputSpec,
current: Record<string, any> = {},
): UntypedFormGroup {
return this.getFormGroup(spec, [], current)
}
getUnionSelectSpec(
spec: CT.ValueSpecUnion,
spec: IST.ValueSpecUnion,
selection: string | null,
): CT.ValueSpecSelect {
): IST.ValueSpecSelect {
return {
...spec,
type: 'select',
@@ -38,7 +38,7 @@ export class FormService {
}
getUnionObject(
spec: CT.ValueSpecUnion,
spec: IST.ValueSpecUnion,
selected: string | null,
): UntypedFormGroup {
const group = this.getFormGroup({
@@ -53,16 +53,16 @@ export class FormService {
return group
}
getListItem(spec: CT.ValueSpecList, entry?: any) {
if (CT.isValueSpecListOf(spec, 'text')) {
getListItem(spec: IST.ValueSpecList, entry?: any) {
if (IST.isValueSpecListOf(spec, 'text')) {
return this.formBuilder.control(entry, stringValidators(spec.spec))
} else if (CT.isValueSpecListOf(spec, 'object')) {
} else if (IST.isValueSpecListOf(spec, 'object')) {
return this.getFormGroup(spec.spec.spec, [], entry)
}
}
getFormGroup(
config: CT.InputSpec,
config: IST.InputSpec,
validators: ValidatorFn[] = [],
current?: Record<string, any> | null,
): UntypedFormGroup {
@@ -77,7 +77,7 @@ export class FormService {
}
private getFormEntry(
spec: CT.ValueSpec,
spec: IST.ValueSpec,
currentValue?: any,
): UntypedFormGroup | UntypedFormArray | UntypedFormControl {
let value: any
@@ -145,18 +145,18 @@ export class FormService {
}
}
// function getListItemValidators(spec: CT.ValueSpecList) {
// if (CT.isValueSpecListOf(spec, 'text')) {
// function getListItemValidators(spec: IST.ValueSpecList) {
// if (IST.isValueSpecListOf(spec, 'text')) {
// return stringValidators(spec.spec)
// }
// }
function stringValidators(
spec: CT.ValueSpecText | CT.ListValueSpecText,
spec: IST.ValueSpecText | IST.ListValueSpecText,
): ValidatorFn[] {
const validators: ValidatorFn[] = []
if ((spec as CT.ValueSpecText).required) {
if ((spec as IST.ValueSpecText).required) {
validators.push(Validators.required)
}
@@ -169,7 +169,7 @@ function stringValidators(
return validators
}
function textareaValidators(spec: CT.ValueSpecTextarea): ValidatorFn[] {
function textareaValidators(spec: IST.ValueSpecTextarea): ValidatorFn[] {
const validators: ValidatorFn[] = []
if (spec.required) {
@@ -181,7 +181,7 @@ function textareaValidators(spec: CT.ValueSpecTextarea): ValidatorFn[] {
return validators
}
function colorValidators({ required }: CT.ValueSpecColor): ValidatorFn[] {
function colorValidators({ required }: IST.ValueSpecColor): ValidatorFn[] {
const validators: ValidatorFn[] = [Validators.pattern(/^#[0-9a-f]{6}$/i)]
if (required) {
@@ -195,7 +195,7 @@ function datetimeValidators({
required,
min,
max,
}: CT.ValueSpecDatetime): ValidatorFn[] {
}: IST.ValueSpecDatetime): ValidatorFn[] {
const validators: ValidatorFn[] = []
if (required) {
@@ -213,12 +213,12 @@ function datetimeValidators({
return validators
}
function numberValidators(spec: CT.ValueSpecNumber): ValidatorFn[] {
function numberValidators(spec: IST.ValueSpecNumber): ValidatorFn[] {
const validators: ValidatorFn[] = []
validators.push(isNumber())
if ((spec as CT.ValueSpecNumber).required) {
if ((spec as IST.ValueSpecNumber).required) {
validators.push(Validators.required)
}
@@ -231,7 +231,7 @@ function numberValidators(spec: CT.ValueSpecNumber): ValidatorFn[] {
return validators
}
function selectValidators(spec: CT.ValueSpecSelect): ValidatorFn[] {
function selectValidators(spec: IST.ValueSpecSelect): ValidatorFn[] {
const validators: ValidatorFn[] = []
if (spec.required) {
@@ -241,13 +241,13 @@ function selectValidators(spec: CT.ValueSpecSelect): ValidatorFn[] {
return validators
}
function multiselectValidators(spec: CT.ValueSpecMultiselect): ValidatorFn[] {
function multiselectValidators(spec: IST.ValueSpecMultiselect): ValidatorFn[] {
const validators: ValidatorFn[] = []
validators.push(listInRange(spec.minLength, spec.maxLength))
return validators
}
function listValidators(spec: CT.ValueSpecList): ValidatorFn[] {
function listValidators(spec: IST.ValueSpecList): ValidatorFn[] {
const validators: ValidatorFn[] = []
validators.push(listInRange(spec.minLength, spec.maxLength))
validators.push(listItemIssue())
@@ -352,7 +352,7 @@ export function listItemIssue(): ValidatorFn {
}
}
export function listUnique(spec: CT.ValueSpecList): ValidatorFn {
export function listUnique(spec: IST.ValueSpecList): ValidatorFn {
return control => {
const list = control.value
for (let idx = 0; idx < list.length; idx++) {
@@ -389,7 +389,11 @@ export function listUnique(spec: CT.ValueSpecList): ValidatorFn {
}
}
function listItemEquals(spec: CT.ValueSpecList, val1: any, val2: any): boolean {
function listItemEquals(
spec: IST.ValueSpecList,
val1: any,
val2: any,
): boolean {
// TODO: fix types
switch (spec.spec.type) {
case 'text':
@@ -402,7 +406,7 @@ function listItemEquals(spec: CT.ValueSpecList, val1: any, val2: any): boolean {
}
}
function itemEquals(spec: CT.ValueSpec, val1: any, val2: any): boolean {
function itemEquals(spec: IST.ValueSpec, val1: any, val2: any): boolean {
switch (spec.type) {
case 'text':
case 'textarea':
@@ -414,15 +418,15 @@ function itemEquals(spec: CT.ValueSpec, val1: any, val2: any): boolean {
// TODO: 'unique-by' does not exist on ValueSpecObject, fix types
return objEquals(
(spec as any)['unique-by'],
spec as CT.ValueSpecObject,
spec as IST.ValueSpecObject,
val1,
val2,
)
case 'union':
// TODO: 'unique-by' does not exist on CT.ValueSpecUnion, fix types
// TODO: 'unique-by' does not exist onIST.ValueSpecUnion, fix types
return unionEquals(
(spec as any)['unique-by'],
spec as CT.ValueSpecUnion,
spec as IST.ValueSpecUnion,
val1,
val2,
)
@@ -442,8 +446,8 @@ function itemEquals(spec: CT.ValueSpec, val1: any, val2: any): boolean {
}
function listObjEquals(
uniqueBy: CT.UniqueBy,
spec: CT.ListValueSpecObject,
uniqueBy: IST.UniqueBy,
spec: IST.ListValueSpecObject,
val1: any,
val2: any,
): boolean {
@@ -470,8 +474,8 @@ function listObjEquals(
}
function objEquals(
uniqueBy: CT.UniqueBy,
spec: CT.ValueSpecObject,
uniqueBy: IST.UniqueBy,
spec: IST.ValueSpecObject,
val1: any,
val2: any,
): boolean {
@@ -499,8 +503,8 @@ function objEquals(
}
function unionEquals(
uniqueBy: CT.UniqueBy,
spec: CT.ValueSpecUnion,
uniqueBy: IST.UniqueBy,
spec: IST.ValueSpecUnion,
val1: any,
val2: any,
): boolean {
@@ -532,8 +536,8 @@ function unionEquals(
}
function uniqueByMessageWrapper(
uniqueBy: CT.UniqueBy,
spec: CT.ListValueSpecObject,
uniqueBy: IST.UniqueBy,
spec: IST.ListValueSpecObject,
) {
let configSpec = spec.spec
@@ -544,8 +548,8 @@ function uniqueByMessageWrapper(
}
function uniqueByMessage(
uniqueBy: CT.UniqueBy,
configSpec: CT.InputSpec,
uniqueBy: IST.UniqueBy,
configSpec: IST.InputSpec,
outermost = true,
): string {
let joinFunc
@@ -554,7 +558,7 @@ function uniqueByMessage(
return ''
} else if (typeof uniqueBy === 'string') {
return configSpec[uniqueBy]
? (configSpec[uniqueBy] as CT.ValueSpecObject).name
? (configSpec[uniqueBy] as IST.ValueSpecObject).name
: uniqueBy
} else if ('any' in uniqueBy) {
joinFunc = ' OR '
@@ -574,14 +578,14 @@ function uniqueByMessage(
}
function isObject(
spec: CT.ListValueSpecOf<any>,
): spec is CT.ListValueSpecObject {
spec: IST.ListValueSpecOf<any>,
): spec is IST.ListValueSpecObject {
// only lists of objects have uniqueBy
return 'uniqueBy' in spec
}
export function convertValuesRecursive(
configSpec: CT.InputSpec,
configSpec: IST.InputSpec,
group: UntypedFormGroup,
) {
Object.entries(configSpec).forEach(([key, valueSpec]) => {
@@ -611,7 +615,7 @@ export function convertValuesRecursive(
})
} else if (valueSpec.spec.type === 'object') {
controls.forEach(formGroup => {
const objectSpec = valueSpec.spec as CT.ListValueSpecObject
const objectSpec = valueSpec.spec as IST.ListValueSpecObject
convertValuesRecursive(objectSpec.spec, formGroup as UntypedFormGroup)
})
}