@ankhorage/contracts 21.0.0 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/appManifest/apis.d.ts +3 -3
- package/dist/appManifest/apis.d.ts.map +1 -1
- package/dist/appManifest/apis.js +4 -6
- package/dist/appManifest/apis.js.map +1 -1
- package/dist/appManifest/bindings.d.ts.map +1 -1
- package/dist/appManifest/bindings.js +2 -1
- package/dist/appManifest/bindings.js.map +1 -1
- package/dist/appManifest/data.d.ts.map +1 -1
- package/dist/appManifest/data.js +5 -4
- package/dist/appManifest/data.js.map +1 -1
- package/dist/appManifest/isAppManifest.js +3 -3
- package/dist/appManifest/isAppManifest.js.map +1 -1
- package/dist/appManifest/isManifestValue.d.ts +1 -1
- package/dist/appManifest/isManifestValue.d.ts.map +1 -1
- package/dist/appManifest/isManifestValue.js +3 -12
- package/dist/appManifest/isManifestValue.js.map +1 -1
- package/dist/appManifest/screens.d.ts +3 -2
- package/dist/appManifest/screens.d.ts.map +1 -1
- package/dist/appManifest/screens.js +15 -7
- package/dist/appManifest/screens.js.map +1 -1
- package/dist/bindings.d.ts +2 -3
- package/dist/bindings.d.ts.map +1 -1
- package/dist/bindings.js.map +1 -1
- package/dist/collections.d.ts +4 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +6 -0
- package/dist/collections.js.map +1 -0
- package/dist/data/apis.d.ts +1 -1
- package/dist/data/apis.d.ts.map +1 -1
- package/dist/data/apis.js.map +1 -1
- package/dist/data/values.d.ts +2 -3
- package/dist/data/values.d.ts.map +1 -1
- package/dist/data/values.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/infra/isInfraEnvironmentSpec.d.ts.map +1 -1
- package/dist/infra/isInfraEnvironmentSpec.js +10 -12
- package/dist/infra/isInfraEnvironmentSpec.js.map +1 -1
- package/dist/infra/isInfraManifest.d.ts.map +1 -1
- package/dist/infra/isInfraManifest.js +14 -5
- package/dist/infra/isInfraManifest.js.map +1 -1
- package/dist/infra/isInfraWorkloadSpec.d.ts.map +1 -1
- package/dist/infra/isInfraWorkloadSpec.js +26 -20
- package/dist/infra/isInfraWorkloadSpec.js.map +1 -1
- package/dist/requirements.d.ts +5 -10
- package/dist/requirements.d.ts.map +1 -1
- package/dist/requirements.js.map +1 -1
- package/dist/serializable.d.ts +6 -0
- package/dist/serializable.d.ts.map +1 -0
- package/dist/serializable.js +14 -0
- package/dist/serializable.js.map +1 -0
- package/dist/state.d.ts +2 -3
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js.map +1 -1
- package/dist/types/infraManifest.d.ts +14 -13
- package/dist/types/infraManifest.d.ts.map +1 -1
- package/dist/types/infraManifest.js.map +1 -1
- package/dist/types/infraWorkload.d.ts +11 -11
- package/dist/types/infraWorkload.d.ts.map +1 -1
- package/dist/types/infraWorkload.js.map +1 -1
- package/dist/types.d.ts +9 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/appManifest/apis.ts +9 -6
- package/src/appManifest/bindings.ts +7 -1
- package/src/appManifest/data.ts +13 -4
- package/src/appManifest/isAppManifest.ts +3 -3
- package/src/appManifest/isManifestValue.ts +3 -16
- package/src/appManifest/screens.ts +21 -10
- package/src/appManifest.test.ts +21 -16
- package/src/bindings.test.ts +11 -8
- package/src/bindings.ts +2 -9
- package/src/collections.ts +8 -0
- package/src/contracts.test.ts +16 -13
- package/src/data/apis.test.ts +6 -4
- package/src/data/apis.ts +1 -1
- package/src/data/values.ts +3 -9
- package/src/deploy.test.ts +4 -4
- package/src/index.ts +2 -0
- package/src/infra/isInfraEnvironmentSpec.ts +16 -16
- package/src/infra/isInfraManifest.ts +17 -6
- package/src/infra/isInfraWorkloadSpec.ts +39 -24
- package/src/infra-published-port.test.ts +8 -8
- package/src/infra-workload-persistence.test.ts +4 -4
- package/src/infra-workload.test.ts +24 -22
- package/src/infra.test.ts +16 -20
- package/src/infraPersistence.test.ts +1 -1
- package/src/infraServices.test.ts +1 -1
- package/src/requirements.test.ts +2 -2
- package/src/requirements.ts +6 -12
- package/src/secrets.test.ts +1 -1
- package/src/serializable.ts +25 -0
- package/src/state.ts +3 -6
- package/src/types/infraManifest.ts +17 -13
- package/src/types/infraWorkload.ts +12 -11
- package/src/types.ts +11 -12
package/dist/data/apis.d.ts
CHANGED
|
@@ -50,5 +50,5 @@ export interface InternalRestApiDefinition extends ApiBaseDefinition {
|
|
|
50
50
|
readonly basePath: string;
|
|
51
51
|
}
|
|
52
52
|
export type ApiDefinition = ExternalGraphQlApiDefinition | ExternalRestApiDefinition | InternalRestApiDefinition;
|
|
53
|
-
export type
|
|
53
|
+
export type ApiDefinitionRegistry = Readonly<Record<ApiId, ApiDefinition>>;
|
|
54
54
|
//# sourceMappingURL=apis.d.ts.map
|
package/dist/data/apis.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apis.d.ts","sourceRoot":"","sources":["../../src/data/apis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAChD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ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AC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC;CACvC;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,4BAA6B,SAAQ,iBAAiB;IACrE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,0BAA0B,CAAC;CACrD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,aAAa,GACvB,4BAA4B,GAAG,yBAAyB,GAAG,yBAAyB,CAAC;AAEvF,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC"}
|
package/dist/data/apis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apis.js","sourceRoot":"","sources":["../../src/data/apis.ts"],"names":[],"mappings":"","sourcesContent":["import type { DataEndpointRegistry } from './endpoints';\nimport type { ApiId } from './ids';\nimport type { CredentialRef } from './refs';\nimport type { DataSchemaRegistry } from './schemas';\nimport type { DataContractValue } from './values';\n\nexport type ApiOrigin = 'external' | 'internal';\nexport type ApiProtocol = 'graphql' | 'rest';\n\nexport interface ApiBaseDefinition {\n readonly id: ApiId;\n readonly origin: ApiOrigin;\n readonly protocol: ApiProtocol;\n readonly name?: string;\n readonly description?: string;\n readonly credential?: CredentialRef;\n readonly endpoints: DataEndpointRegistry;\n readonly schemas?: DataSchemaRegistry;\n readonly metadata?: DataContractValue;\n}\n\nexport interface OpenApiDocumentRef {\n readonly url?: string;\n readonly documentId?: string;\n readonly version?: string;\n}\n\nexport interface ExternalRestApiDefinition extends ApiBaseDefinition {\n readonly origin: 'external';\n readonly protocol: 'rest';\n readonly baseUrl: string;\n readonly openApi?: OpenApiDocumentRef;\n}\n\nexport interface GraphQlIntrospectionConfig {\n readonly enabled: boolean;\n readonly schemaVersion?: string;\n}\n\nexport interface ExternalGraphQlApiDefinition extends ApiBaseDefinition {\n readonly origin: 'external';\n readonly protocol: 'graphql';\n readonly endpointUrl: string;\n readonly introspection?: GraphQlIntrospectionConfig;\n}\n\n/**\n * Consumer-facing identity for an Ankhorage-owned API.\n *\n * Internal API generation/execution is intentionally not part of the current\n * contract. `basePath` reserves the portable API-facing location only; later\n * infrastructure/runtime packages may implement it without changing bindings.\n */\nexport interface InternalRestApiDefinition extends ApiBaseDefinition {\n readonly origin: 'internal';\n readonly protocol: 'rest';\n readonly basePath: string;\n}\n\nexport type ApiDefinition =\n ExternalGraphQlApiDefinition | ExternalRestApiDefinition | InternalRestApiDefinition;\n\nexport type
|
|
1
|
+
{"version":3,"file":"apis.js","sourceRoot":"","sources":["../../src/data/apis.ts"],"names":[],"mappings":"","sourcesContent":["import type { DataEndpointRegistry } from './endpoints';\nimport type { ApiId } from './ids';\nimport type { CredentialRef } from './refs';\nimport type { DataSchemaRegistry } from './schemas';\nimport type { DataContractValue } from './values';\n\nexport type ApiOrigin = 'external' | 'internal';\nexport type ApiProtocol = 'graphql' | 'rest';\n\nexport interface ApiBaseDefinition {\n readonly id: ApiId;\n readonly origin: ApiOrigin;\n readonly protocol: ApiProtocol;\n readonly name?: string;\n readonly description?: string;\n readonly credential?: CredentialRef;\n readonly endpoints: DataEndpointRegistry;\n readonly schemas?: DataSchemaRegistry;\n readonly metadata?: DataContractValue;\n}\n\nexport interface OpenApiDocumentRef {\n readonly url?: string;\n readonly documentId?: string;\n readonly version?: string;\n}\n\nexport interface ExternalRestApiDefinition extends ApiBaseDefinition {\n readonly origin: 'external';\n readonly protocol: 'rest';\n readonly baseUrl: string;\n readonly openApi?: OpenApiDocumentRef;\n}\n\nexport interface GraphQlIntrospectionConfig {\n readonly enabled: boolean;\n readonly schemaVersion?: string;\n}\n\nexport interface ExternalGraphQlApiDefinition extends ApiBaseDefinition {\n readonly origin: 'external';\n readonly protocol: 'graphql';\n readonly endpointUrl: string;\n readonly introspection?: GraphQlIntrospectionConfig;\n}\n\n/**\n * Consumer-facing identity for an Ankhorage-owned API.\n *\n * Internal API generation/execution is intentionally not part of the current\n * contract. `basePath` reserves the portable API-facing location only; later\n * infrastructure/runtime packages may implement it without changing bindings.\n */\nexport interface InternalRestApiDefinition extends ApiBaseDefinition {\n readonly origin: 'internal';\n readonly protocol: 'rest';\n readonly basePath: string;\n}\n\nexport type ApiDefinition =\n ExternalGraphQlApiDefinition | ExternalRestApiDefinition | InternalRestApiDefinition;\n\nexport type ApiDefinitionRegistry = Readonly<Record<ApiId, ApiDefinition>>;\n"]}
|
package/dist/data/values.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
};
|
|
1
|
+
import type { SerializableValue } from '../serializable';
|
|
2
|
+
export type DataContractValue = SerializableValue;
|
|
4
3
|
export type DataPath = string;
|
|
5
4
|
//# sourceMappingURL=values.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/data/values.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/data/values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC"}
|
package/dist/data/values.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../src/data/values.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../src/data/values.ts"],"names":[],"mappings":"","sourcesContent":["import type { SerializableValue } from '../serializable';\n\nexport type DataContractValue = SerializableValue;\n\nexport type DataPath = string;\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './appManifest';
|
|
|
2
2
|
export * from './auth';
|
|
3
3
|
export * from './bindings';
|
|
4
4
|
export * from './cli';
|
|
5
|
+
export * from './collections';
|
|
5
6
|
export * from './data';
|
|
6
7
|
export * from './db';
|
|
7
8
|
export * from './deploy';
|
|
@@ -14,6 +15,7 @@ export * from './repository';
|
|
|
14
15
|
export * from './requirements';
|
|
15
16
|
export * from './runtimeCallbacks';
|
|
16
17
|
export * from './secrets';
|
|
18
|
+
export * from './serializable';
|
|
17
19
|
export * from './state';
|
|
18
20
|
export * from './storage';
|
|
19
21
|
export * from './theme';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,MAAM,CAAC;AACrB,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,MAAM,CAAC;AACrB,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './appManifest';
|
|
|
2
2
|
export * from './auth';
|
|
3
3
|
export * from './bindings';
|
|
4
4
|
export * from './cli';
|
|
5
|
+
export * from './collections';
|
|
5
6
|
export * from './data';
|
|
6
7
|
export * from './db';
|
|
7
8
|
export * from './deploy';
|
|
@@ -14,6 +15,7 @@ export * from './repository';
|
|
|
14
15
|
export * from './requirements';
|
|
15
16
|
export * from './runtimeCallbacks';
|
|
16
17
|
export * from './secrets';
|
|
18
|
+
export * from './serializable';
|
|
17
19
|
export * from './state';
|
|
18
20
|
export * from './storage';
|
|
19
21
|
export * from './theme';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,MAAM,CAAC;AACrB,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,MAAM,CAAC","sourcesContent":["export * from './appManifest';\nexport * from './auth';\nexport * from './bindings';\nexport * from './cli';\nexport * from './data';\nexport * from './db';\nexport * from './deploy';\nexport * from './deployProvider';\nexport * from './environments';\nexport * from './infra';\nexport * from './media';\nexport * from './navigator';\nexport * from './repository';\nexport * from './requirements';\nexport * from './runtimeCallbacks';\nexport * from './secrets';\nexport * from './state';\nexport * from './storage';\nexport * from './theme';\nexport * from './types';\nexport * from './ui';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,MAAM,CAAC;AACrB,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,MAAM,CAAC","sourcesContent":["export * from './appManifest';\nexport * from './auth';\nexport * from './bindings';\nexport * from './cli';\nexport * from './collections';\nexport * from './data';\nexport * from './db';\nexport * from './deploy';\nexport * from './deployProvider';\nexport * from './environments';\nexport * from './infra';\nexport * from './media';\nexport * from './navigator';\nexport * from './repository';\nexport * from './requirements';\nexport * from './runtimeCallbacks';\nexport * from './secrets';\nexport * from './serializable';\nexport * from './state';\nexport * from './storage';\nexport * from './theme';\nexport * from './types';\nexport * from './ui';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInfraEnvironmentSpec.d.ts","sourceRoot":"","sources":["../../src/infra/isInfraEnvironmentSpec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isInfraEnvironmentSpec.d.ts","sourceRoot":"","sources":["../../src/infra/isInfraEnvironmentSpec.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EAIrB,MAAM,wBAAwB,CAAC;AAUhC,8FAA8F;AAC9F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAOpF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isRecord } from '@ankhorage/utility/object';
|
|
2
2
|
import { isNonEmptyString } from '@ankhorage/utility/string';
|
|
3
|
+
import { isSerializableSet } from '../collections';
|
|
3
4
|
import { INFRA_ADAPTER_CATALOG } from './constants';
|
|
4
5
|
import { infraFields } from './infraFields';
|
|
5
6
|
import { isInfraAuthSpec } from './isInfraAuthSpec';
|
|
@@ -74,13 +75,11 @@ function hasNetworkingRelationships(value) {
|
|
|
74
75
|
}
|
|
75
76
|
/*** Validate portable, unique Cerbos policy files without host paths or traversal. */
|
|
76
77
|
function isPolicyFiles(value) {
|
|
77
|
-
return (
|
|
78
|
-
value.every((
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
new Set(value.map((policy) => (isRecord(policy) ? policy.path : undefined))).size ===
|
|
83
|
-
value.length);
|
|
78
|
+
return (isRecord(value) &&
|
|
79
|
+
Object.entries(value).every(([path, content]) => isNonEmptyString(path) &&
|
|
80
|
+
!path.startsWith('/') &&
|
|
81
|
+
!path.split('/').includes('..') &&
|
|
82
|
+
isNonEmptyString(content)));
|
|
84
83
|
}
|
|
85
84
|
/*** Validate provider-neutral scheduled database backup intent. */
|
|
86
85
|
function isScheduledDatabaseBackup(value) {
|
|
@@ -107,7 +106,7 @@ function isObjectStorage(value) {
|
|
|
107
106
|
return false;
|
|
108
107
|
const common = {
|
|
109
108
|
provider: (provider) => provider === value.provider,
|
|
110
|
-
buckets:
|
|
109
|
+
buckets: (buckets) => buckets === undefined || isSerializableSet(buckets),
|
|
111
110
|
};
|
|
112
111
|
if (value.provider === 'supabase') {
|
|
113
112
|
return isInfraShape(value, {
|
|
@@ -125,13 +124,12 @@ function isObjectStorage(value) {
|
|
|
125
124
|
}
|
|
126
125
|
/*** Duplicate desired workload identities cannot be reconciled safely. */
|
|
127
126
|
function isWorkloads(value) {
|
|
128
|
-
return (
|
|
129
|
-
value.every(isInfraWorkloadSpec) &&
|
|
130
|
-
new Set(value.map((workload) => workload.id)).size === value.length);
|
|
127
|
+
return (isRecord(value) &&
|
|
128
|
+
Object.entries(value).every(([workloadId, workload]) => isInfraWorkloadSpec(workload) && workload.id === workloadId));
|
|
131
129
|
}
|
|
132
130
|
/*** Prevent two workloads in one environment from claiming the same external listener. */
|
|
133
131
|
function hasUniquePublishedPorts(value) {
|
|
134
|
-
const ports = (value.workloads ??
|
|
132
|
+
const ports = Object.values(value.workloads ?? {}).flatMap((workload) => Object.values(workload.ports ?? {}).flatMap(({ publishedPort }) => publishedPort === undefined ? [] : [publishedPort]));
|
|
135
133
|
return new Set(ports).size === ports.length;
|
|
136
134
|
}
|
|
137
135
|
/*** Check catalog dependencies against selected sibling capabilities and runtime capabilities. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInfraEnvironmentSpec.js","sourceRoot":"","sources":["../../src/infra/isInfraEnvironmentSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAS7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,8FAA8F;AAC9F,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,OAAO,CACL,kBAAkB,CAAC,KAAK,CAAC;QACzB,sBAAsB,CAAC,KAAK,CAAC;QAC7B,0BAA0B,CAAC,KAAK,CAAC;QACjC,uBAAuB,CAAC,KAAK,CAAC,CAC/B,CAAC;AACJ,CAAC;AAED,2FA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AAG,CAAS;QACnC,SAAS;QACT,GAAG,CAAC,OAAO,EAAE,YAAY,IAAI,EAAE,CAAC;QAChC,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;aACrB,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,SAAS,KAAK,SAAS,CAAC;aAClD,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC;KACrC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC;SACxC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,QAAQ,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC;SACnF,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAC9F,CAAC","sourcesContent":["import { isRecord } from '@ankhorage/utility/object';\nimport { isNonEmptyString } from '@ankhorage/utility/string';\n\nimport type {\n InfraEnvironmentSpec,\n InfraObjectStorageSpec,\n InfraS3PersistenceTarget,\n InfraScheduledDatabaseBackupSpec,\n} from '../types/infraManifest';\nimport type { InfraShape } from '../types/infraValidation';\nimport { INFRA_ADAPTER_CATALOG } from './constants';\nimport { infraFields } from './infraFields';\nimport { isInfraAuthSpec } from './isInfraAuthSpec';\nimport { isInfraCredentialRef } from './isInfraCredentialRef';\nimport { isInfraDeploymentSpec } from './isInfraDeploymentSpec';\nimport { isInfraShape } from './isInfraShape';\nimport { isInfraWorkloadSpec } from './isInfraWorkloadSpec';\n\n/*** Validate sibling capabilities and their required relationships within one environment. */\nexport function isInfraEnvironmentSpec(value: unknown): value is InfraEnvironmentSpec {\n return (\n isEnvironmentShape(value) &&\n hasServiceDependencies(value) &&\n hasNetworkingRelationships(value) &&\n hasUniquePublishedPorts(value)\n );\n}\n\n/*** Check all environment field shapes before inspecting canonical dependency metadata. */\nfunction isEnvironmentShape(value: unknown): value is InfraEnvironmentSpec {\n return isInfraShape(value, {\n deployment: isInfraDeploymentSpec,\n database: (database) =>\n database === undefined ||\n isInfraShape(database, {\n provider: (provider) => provider === 'supabase',\n tier: (tier) => tier === undefined || tier === 'dev' || tier === 'prod',\n backup: (backup) => backup === undefined || isScheduledDatabaseBackup(backup),\n }),\n objectStorage: (storage) => storage === undefined || isObjectStorage(storage),\n auth: (auth) => auth === undefined || isInfraAuthSpec(auth),\n authz: (authz) =>\n authz === undefined ||\n isInfraShape(authz, {\n provider: (provider) => provider === 'cerbos',\n kind: (kind) => kind === 'ABAC' || kind === 'RBAC',\n policies: (policies) => policies === undefined || isPolicyFiles(policies),\n }),\n secretStore: (store) =>\n store === undefined ||\n isInfraShape(store, {\n provider: (provider) => provider === 'supabase-vault',\n schema: infraFields.optionalText,\n }),\n networking: (networking) =>\n networking === undefined ||\n isInfraShape(networking, {\n domain: infraFields.optionalText,\n publicBaseUrl: (publicBaseUrl) =>\n publicBaseUrl === undefined || isPublicHttpOrigin(publicBaseUrl),\n tls: (tls) =>\n tls === undefined ||\n isInfraShape(tls, {\n mode: (mode) => mode === 'acme-http-01',\n contactEmail: isNonEmptyString,\n }),\n }),\n workloads: (workloads) => workloads === undefined || isWorkloads(workloads),\n } satisfies InfraShape<InfraEnvironmentSpec>);\n}\n\n/*** Public workload configuration uses one canonical absolute HTTP(S) origin without path state. */\nfunction isPublicHttpOrigin(value: unknown): boolean {\n if (!isNonEmptyString(value)) return false;\n try {\n const url = new URL(value);\n return (url.protocol === 'http:' || url.protocol === 'https:') && url.origin === value;\n } catch {\n return false;\n }\n}\n\n/*** Automatic TLS requires one matching HTTPS origin and public DNS hostname. */\nfunction hasNetworkingRelationships(value: InfraEnvironmentSpec): boolean {\n const { networking } = value;\n if (networking?.tls === undefined) return true;\n if (networking.domain === undefined || networking.publicBaseUrl === undefined) return false;\n const url = new URL(networking.publicBaseUrl);\n return url.protocol === 'https:' && url.hostname === networking.domain;\n}\n\n/*** Validate portable, unique Cerbos policy files without host paths or traversal. */\nfunction isPolicyFiles(value: unknown): boolean {\n return (\n Array.isArray(value) &&\n value.every((policy) =>\n isInfraShape(policy, {\n path: (path) =>\n isNonEmptyString(path) && !path.startsWith('/') && !path.split('/').includes('..'),\n content: isNonEmptyString,\n }),\n ) &&\n new Set(value.map((policy) => (isRecord(policy) ? policy.path : undefined))).size ===\n value.length\n );\n}\n\n/*** Validate provider-neutral scheduled database backup intent. */\nfunction isScheduledDatabaseBackup(value: unknown): value is InfraScheduledDatabaseBackupSpec {\n return isInfraShape(value, {\n mode: (mode) => mode === 'scheduled',\n target: isS3PersistenceTarget,\n intervalHours: (interval) =>\n interval === undefined ||\n (typeof interval === 'number' && Number.isInteger(interval) && interval > 0),\n });\n}\n\n/*** Validate one portable S3-compatible persistence target without resolving credentials. */\nfunction isS3PersistenceTarget(value: unknown): value is InfraS3PersistenceTarget {\n return isInfraShape(value, {\n endpoint: isPublicHttpOrigin,\n region: isNonEmptyString,\n bucket: isNonEmptyString,\n credentials: isInfraCredentialRef,\n forcePathStyle: (forcePathStyle) =>\n forcePathStyle === undefined || typeof forcePathStyle === 'boolean',\n });\n}\n\n/*** Object storage can vary independently from database/auth; there is no implicit auto provider. */\nfunction isObjectStorage(value: unknown): boolean {\n if (!isRecord(value)) return false;\n const common = {\n provider: (provider: unknown) => provider === value.provider,\n buckets: infraFields.optionalStrings,\n };\n if (value.provider === 'supabase') {\n return isInfraShape(value, {\n ...common,\n provider: (provider) => provider === 'supabase',\n backend: (backend) => backend === undefined || isS3PersistenceTarget(backend),\n } satisfies InfraShape<Extract<InfraObjectStorageSpec, { readonly provider: 'supabase' }>>);\n }\n return isInfraShape(value, {\n ...common,\n provider: (provider) => provider === 'r2',\n accountId: infraFields.optionalText,\n credentials: (credentials) => credentials === undefined || isInfraCredentialRef(credentials),\n } satisfies InfraShape<Extract<InfraObjectStorageSpec, { readonly provider: 'r2' }>>);\n}\n\n/*** Duplicate desired workload identities cannot be reconciled safely. */\nfunction isWorkloads(value: unknown): boolean {\n return (\n Array.isArray(value) &&\n value.every(isInfraWorkloadSpec) &&\n new Set(value.map((workload) => workload.id)).size === value.length\n );\n}\n\n/*** Prevent two workloads in one environment from claiming the same external listener. */\nfunction hasUniquePublishedPorts(value: InfraEnvironmentSpec): boolean {\n const ports = (value.workloads ?? []).flatMap((workload) =>\n (workload.ports ?? []).flatMap(({ publishedPort }) =>\n publishedPort === undefined ? [] : [publishedPort],\n ),\n );\n return new Set(ports).size === ports.length;\n}\n\n/*** Check catalog dependencies against selected sibling capabilities and runtime capabilities. */\nfunction hasServiceDependencies(value: InfraEnvironmentSpec): boolean {\n const selections = [\n value.database,\n value.auth,\n value.authz,\n value.objectStorage,\n value.secretStore,\n ];\n const runtime = Object.values(INFRA_ADAPTER_CATALOG).find(\n (entry) => entry.id === value.deployment.runtime.provider,\n );\n const capabilities = new Set<string>([\n 'compute',\n ...(runtime?.capabilities ?? []),\n ...Object.entries(value)\n .filter(([, selection]) => selection !== undefined)\n .map(([capability]) => capability),\n ]);\n return Object.values(INFRA_ADAPTER_CATALOG)\n .filter((entry) => selections.some((selection) => selection?.provider === entry.id))\n .every((entry) => entry.dependencies.every((dependency) => capabilities.has(dependency)));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"isInfraEnvironmentSpec.js","sourceRoot":"","sources":["../../src/infra/isInfraEnvironmentSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAQnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE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,CAAC,QAAQ;QACd,KAAK,CAAC,IAAI;QACV,KAAK,CAAC,KAAK;QACX,KAAK,CAAC,aAAa;QACnB,KAAK,CAAC,WAAW;KAClB,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,IAAI,CACvD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAC1D,CAAC;IACF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAS;QACnC,SAAS;QACT,GAAG,CAAC,OAAO,EAAE,YAAY,IAAI,EAAE,CAAC;QAChC,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;aACrB,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,SAAS,KAAK,SAAS,CAAC;aAClD,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC;KACrC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC;SACxC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,QAAQ,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC;SACnF,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAC9F,CAAC","sourcesContent":["import { isRecord } from '@ankhorage/utility/object';\nimport { isNonEmptyString } from '@ankhorage/utility/string';\n\nimport { isSerializableSet } from '../collections';\nimport type {\n InfraEnvironmentSpec,\n InfraObjectStorageSpec,\n InfraS3PersistenceTarget,\n InfraScheduledDatabaseBackupSpec,\n} from '../types/infraManifest';\nimport type { InfraShape } from '../types/infraValidation';\nimport { INFRA_ADAPTER_CATALOG } from './constants';\nimport { infraFields } from './infraFields';\nimport { isInfraAuthSpec } from './isInfraAuthSpec';\nimport { isInfraCredentialRef } from './isInfraCredentialRef';\nimport { isInfraDeploymentSpec } from './isInfraDeploymentSpec';\nimport { isInfraShape } from './isInfraShape';\nimport { isInfraWorkloadSpec } from './isInfraWorkloadSpec';\n\n/*** Validate sibling capabilities and their required relationships within one environment. */\nexport function isInfraEnvironmentSpec(value: unknown): value is InfraEnvironmentSpec {\n return (\n isEnvironmentShape(value) &&\n hasServiceDependencies(value) &&\n hasNetworkingRelationships(value) &&\n hasUniquePublishedPorts(value)\n );\n}\n\n/*** Check all environment field shapes before inspecting canonical dependency metadata. */\nfunction isEnvironmentShape(value: unknown): value is InfraEnvironmentSpec {\n return isInfraShape(value, {\n deployment: isInfraDeploymentSpec,\n database: (database) =>\n database === undefined ||\n isInfraShape(database, {\n provider: (provider) => provider === 'supabase',\n tier: (tier) => tier === undefined || tier === 'dev' || tier === 'prod',\n backup: (backup) => backup === undefined || isScheduledDatabaseBackup(backup),\n }),\n objectStorage: (storage) => storage === undefined || isObjectStorage(storage),\n auth: (auth) => auth === undefined || isInfraAuthSpec(auth),\n authz: (authz) =>\n authz === undefined ||\n isInfraShape(authz, {\n provider: (provider) => provider === 'cerbos',\n kind: (kind) => kind === 'ABAC' || kind === 'RBAC',\n policies: (policies) => policies === undefined || isPolicyFiles(policies),\n }),\n secretStore: (store) =>\n store === undefined ||\n isInfraShape(store, {\n provider: (provider) => provider === 'supabase-vault',\n schema: infraFields.optionalText,\n }),\n networking: (networking) =>\n networking === undefined ||\n isInfraShape(networking, {\n domain: infraFields.optionalText,\n publicBaseUrl: (publicBaseUrl) =>\n publicBaseUrl === undefined || isPublicHttpOrigin(publicBaseUrl),\n tls: (tls) =>\n tls === undefined ||\n isInfraShape(tls, {\n mode: (mode) => mode === 'acme-http-01',\n contactEmail: isNonEmptyString,\n }),\n }),\n workloads: (workloads) => workloads === undefined || isWorkloads(workloads),\n } satisfies InfraShape<InfraEnvironmentSpec>);\n}\n\n/*** Public workload configuration uses one canonical absolute HTTP(S) origin without path state. */\nfunction isPublicHttpOrigin(value: unknown): boolean {\n if (!isNonEmptyString(value)) return false;\n try {\n const url = new URL(value);\n return (url.protocol === 'http:' || url.protocol === 'https:') && url.origin === value;\n } catch {\n return false;\n }\n}\n\n/*** Automatic TLS requires one matching HTTPS origin and public DNS hostname. */\nfunction hasNetworkingRelationships(value: InfraEnvironmentSpec): boolean {\n const { networking } = value;\n if (networking?.tls === undefined) return true;\n if (networking.domain === undefined || networking.publicBaseUrl === undefined) return false;\n const url = new URL(networking.publicBaseUrl);\n return url.protocol === 'https:' && url.hostname === networking.domain;\n}\n\n/*** Validate portable, unique Cerbos policy files without host paths or traversal. */\nfunction isPolicyFiles(value: unknown): boolean {\n return (\n isRecord(value) &&\n Object.entries(value).every(\n ([path, content]) =>\n isNonEmptyString(path) &&\n !path.startsWith('/') &&\n !path.split('/').includes('..') &&\n isNonEmptyString(content),\n )\n );\n}\n\n/*** Validate provider-neutral scheduled database backup intent. */\nfunction isScheduledDatabaseBackup(value: unknown): value is InfraScheduledDatabaseBackupSpec {\n return isInfraShape(value, {\n mode: (mode) => mode === 'scheduled',\n target: isS3PersistenceTarget,\n intervalHours: (interval) =>\n interval === undefined ||\n (typeof interval === 'number' && Number.isInteger(interval) && interval > 0),\n });\n}\n\n/*** Validate one portable S3-compatible persistence target without resolving credentials. */\nfunction isS3PersistenceTarget(value: unknown): value is InfraS3PersistenceTarget {\n return isInfraShape(value, {\n endpoint: isPublicHttpOrigin,\n region: isNonEmptyString,\n bucket: isNonEmptyString,\n credentials: isInfraCredentialRef,\n forcePathStyle: (forcePathStyle) =>\n forcePathStyle === undefined || typeof forcePathStyle === 'boolean',\n });\n}\n\n/*** Object storage can vary independently from database/auth; there is no implicit auto provider. */\nfunction isObjectStorage(value: unknown): boolean {\n if (!isRecord(value)) return false;\n const common = {\n provider: (provider: unknown) => provider === value.provider,\n buckets: (buckets: unknown) => buckets === undefined || isSerializableSet(buckets),\n };\n if (value.provider === 'supabase') {\n return isInfraShape(value, {\n ...common,\n provider: (provider) => provider === 'supabase',\n backend: (backend) => backend === undefined || isS3PersistenceTarget(backend),\n } satisfies InfraShape<Extract<InfraObjectStorageSpec, { readonly provider: 'supabase' }>>);\n }\n return isInfraShape(value, {\n ...common,\n provider: (provider) => provider === 'r2',\n accountId: infraFields.optionalText,\n credentials: (credentials) => credentials === undefined || isInfraCredentialRef(credentials),\n } satisfies InfraShape<Extract<InfraObjectStorageSpec, { readonly provider: 'r2' }>>);\n}\n\n/*** Duplicate desired workload identities cannot be reconciled safely. */\nfunction isWorkloads(value: unknown): boolean {\n return (\n isRecord(value) &&\n Object.entries(value).every(\n ([workloadId, workload]) => isInfraWorkloadSpec(workload) && workload.id === workloadId,\n )\n );\n}\n\n/*** Prevent two workloads in one environment from claiming the same external listener. */\nfunction hasUniquePublishedPorts(value: InfraEnvironmentSpec): boolean {\n const ports = Object.values(value.workloads ?? {}).flatMap((workload) =>\n Object.values(workload.ports ?? {}).flatMap(({ publishedPort }) =>\n publishedPort === undefined ? [] : [publishedPort],\n ),\n );\n return new Set(ports).size === ports.length;\n}\n\n/*** Check catalog dependencies against selected sibling capabilities and runtime capabilities. */\nfunction hasServiceDependencies(value: InfraEnvironmentSpec): boolean {\n const selections = [\n value.database,\n value.auth,\n value.authz,\n value.objectStorage,\n value.secretStore,\n ];\n const runtime = Object.values(INFRA_ADAPTER_CATALOG).find(\n (entry) => entry.id === value.deployment.runtime.provider,\n );\n const capabilities = new Set<string>([\n 'compute',\n ...(runtime?.capabilities ?? []),\n ...Object.entries(value)\n .filter(([, selection]) => selection !== undefined)\n .map(([capability]) => capability),\n ]);\n return Object.values(INFRA_ADAPTER_CATALOG)\n .filter((entry) => selections.some((selection) => selection?.provider === entry.id))\n .every((entry) => entry.dependencies.every((dependency) => capabilities.has(dependency)));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInfraManifest.d.ts","sourceRoot":"","sources":["../../src/infra/isInfraManifest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isInfraManifest.d.ts","sourceRoot":"","sources":["../../src/infra/isInfraManifest.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,wBAAwB,CAAC;AAK7E,wGAAwG;AACxG,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAMtE"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { isRecord } from '@ankhorage/utility/object';
|
|
2
|
-
import {
|
|
2
|
+
import { isApiDefinitionRegistry } from '../appManifest/apis';
|
|
3
3
|
import { APP_ENVIRONMENT_IDS } from '../environments';
|
|
4
|
-
import {
|
|
4
|
+
import { isSerializableValue } from '../serializable';
|
|
5
5
|
import { isInfraEnvironmentSpec } from './isInfraEnvironmentSpec';
|
|
6
6
|
import { isInfraShape } from './isInfraShape';
|
|
7
7
|
/*** Validate standalone infrastructure without AppManifest, Deploy or provider package side effects. */
|
|
8
8
|
export function isInfraManifest(value) {
|
|
9
9
|
return isInfraShape(value, {
|
|
10
10
|
environments: isEnvironments,
|
|
11
|
-
apis: (apis) => apis === undefined ||
|
|
12
|
-
modules:
|
|
13
|
-
modulesConfig: (config) => config === undefined || isRecord(config),
|
|
11
|
+
apis: (apis) => apis === undefined || isApiDefinitionRegistry(apis),
|
|
12
|
+
modules: isModuleRegistry,
|
|
14
13
|
});
|
|
15
14
|
}
|
|
16
15
|
/*** Local is required; preview and production are optional but never inferred from arbitrary keys. */
|
|
@@ -20,4 +19,14 @@ function isEnvironments(value) {
|
|
|
20
19
|
return Object.entries(value).every(([key, environment]) => APP_ENVIRONMENT_IDS.some((id) => id === key) &&
|
|
21
20
|
((environment === undefined && key !== 'local') || isInfraEnvironmentSpec(environment)));
|
|
22
21
|
}
|
|
22
|
+
/*** Validate installed module identity and optional serializable module-owned configuration. */
|
|
23
|
+
function isModuleRegistry(value) {
|
|
24
|
+
return isRecord(value) && Object.values(value).every(isModuleSpec);
|
|
25
|
+
}
|
|
26
|
+
/*** Validate one module registry entry. */
|
|
27
|
+
function isModuleSpec(value) {
|
|
28
|
+
return isInfraShape(value, {
|
|
29
|
+
config: (config) => config === undefined || isSerializableValue(config),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
23
32
|
//# sourceMappingURL=isInfraManifest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInfraManifest.js","sourceRoot":"","sources":["../../src/infra/isInfraManifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"isInfraManifest.js","sourceRoot":"","sources":["../../src/infra/isInfraManifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,wGAAwG;AACxG,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,YAAY,CAAC,KAAK,EAAE;QACzB,YAAY,EAAE,cAAc;QAC5B,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,uBAAuB,CAAC,IAAI,CAAC;QACnE,OAAO,EAAE,gBAAgB;KACU,CAAC,CAAC;AACzC,CAAC;AAED,sGAAsG;AACtG,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3E,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAChC,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE,CACrB,mBAAmB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC;QAC5C,CAAC,CAAC,WAAW,KAAK,SAAS,IAAI,GAAG,KAAK,OAAO,CAAC,IAAI,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAC1F,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AACrE,CAAC;AAED,2CAA2C;AAC3C,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,YAAY,CAAC,KAAK,EAAE;QACzB,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,SAAS,IAAI,mBAAmB,CAAC,MAAM,CAAC;KACxE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isRecord } from '@ankhorage/utility/object';\n\nimport { isApiDefinitionRegistry } from '../appManifest/apis';\nimport { APP_ENVIRONMENT_IDS } from '../environments';\nimport { isSerializableValue } from '../serializable';\nimport type { InfraManifest, InfraModuleSpec } from '../types/infraManifest';\nimport type { InfraShape } from '../types/infraValidation';\nimport { isInfraEnvironmentSpec } from './isInfraEnvironmentSpec';\nimport { isInfraShape } from './isInfraShape';\n\n/*** Validate standalone infrastructure without AppManifest, Deploy or provider package side effects. */\nexport function isInfraManifest(value: unknown): value is InfraManifest {\n return isInfraShape(value, {\n environments: isEnvironments,\n apis: (apis) => apis === undefined || isApiDefinitionRegistry(apis),\n modules: isModuleRegistry,\n } satisfies InfraShape<InfraManifest>);\n}\n\n/*** Local is required; preview and production are optional but never inferred from arbitrary keys. */\nfunction isEnvironments(value: unknown): boolean {\n if (!isRecord(value) || !isInfraEnvironmentSpec(value.local)) return false;\n return Object.entries(value).every(\n ([key, environment]) =>\n APP_ENVIRONMENT_IDS.some((id) => id === key) &&\n ((environment === undefined && key !== 'local') || isInfraEnvironmentSpec(environment)),\n );\n}\n\n/*** Validate installed module identity and optional serializable module-owned configuration. */\nfunction isModuleRegistry(value: unknown): boolean {\n return isRecord(value) && Object.values(value).every(isModuleSpec);\n}\n\n/*** Validate one module registry entry. */\nfunction isModuleSpec(value: unknown): value is InfraModuleSpec {\n return isInfraShape(value, {\n config: (config) => config === undefined || isSerializableValue(config),\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInfraWorkloadSpec.d.ts","sourceRoot":"","sources":["../../src/infra/isInfraWorkloadSpec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isInfraWorkloadSpec.d.ts","sourceRoot":"","sources":["../../src/infra/isInfraWorkloadSpec.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAMhE,0GAA0G;AAC1G,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CA8B9E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isStringArray } from '@ankhorage/utility/array';
|
|
2
2
|
import { isRecord } from '@ankhorage/utility/object';
|
|
3
3
|
import { isNonEmptyString } from '@ankhorage/utility/string';
|
|
4
|
+
import { isSerializableSet } from '../collections';
|
|
4
5
|
import { infraFields } from './infraFields';
|
|
5
6
|
import { isInfraShape } from './isInfraShape';
|
|
6
7
|
import { isInfraWorkloadHealth } from './isInfraWorkloadHealth';
|
|
@@ -12,35 +13,33 @@ export function isInfraWorkloadSpec(value) {
|
|
|
12
13
|
artifact: (artifact) => isInfraShape(artifact, { kind: (kind) => kind === 'image', image: isNonEmptyString }),
|
|
13
14
|
command: infraFields.optionalStrings,
|
|
14
15
|
args: (args) => args === undefined || isStringArray(args),
|
|
15
|
-
ports: (ports) => ports === undefined ||
|
|
16
|
-
(Array.isArray(ports) && ports.every(isPort) && hasUniqueField(ports, 'name')),
|
|
16
|
+
ports: (ports) => ports === undefined || isPortRegistry(ports),
|
|
17
17
|
environment: (environment) => environment === undefined ||
|
|
18
18
|
(isRecord(environment) && Object.values(environment).every(isInfraWorkloadValue)),
|
|
19
|
-
files: (files) => files === undefined ||
|
|
20
|
-
(Array.isArray(files) && files.every(isFile) && hasUniqueField(files, 'path')),
|
|
19
|
+
files: (files) => files === undefined || isFileMap(files),
|
|
21
20
|
health: (health) => health === undefined || isInfraWorkloadHealth(health),
|
|
22
21
|
resources: (resources) => resources === undefined ||
|
|
23
22
|
isInfraShape(resources, {
|
|
24
23
|
cpuMillis: infraFields.optionalPositiveInteger,
|
|
25
24
|
memoryMiB: infraFields.optionalPositiveInteger,
|
|
26
25
|
}),
|
|
27
|
-
persistence: (volumes) => volumes === undefined ||
|
|
28
|
-
(Array.isArray(volumes) &&
|
|
29
|
-
volumes.every(isVolume) &&
|
|
30
|
-
hasUniqueField(volumes, 'id') &&
|
|
31
|
-
hasUniqueField(volumes, 'mountPath')),
|
|
26
|
+
persistence: (volumes) => volumes === undefined || isVolumeRegistry(volumes),
|
|
32
27
|
exposure: (exposure) => exposure === undefined || exposure === 'internal' || exposure === 'public',
|
|
33
28
|
replicas: infraFields.optionalNonnegativeInteger,
|
|
34
|
-
dependsOn:
|
|
29
|
+
dependsOn: (dependsOn) => dependsOn === undefined || isSerializableSet(dependsOn),
|
|
35
30
|
})) {
|
|
36
31
|
return false;
|
|
37
32
|
}
|
|
38
33
|
return hasValidPublishedPorts(value);
|
|
39
34
|
}
|
|
35
|
+
/*** Validate named transport ports keyed by their stable authored name. */
|
|
36
|
+
function isPortRegistry(value) {
|
|
37
|
+
return (isRecord(value) &&
|
|
38
|
+
Object.entries(value).every(([name, port]) => isNonEmptyString(name) && isPort(port)));
|
|
39
|
+
}
|
|
40
40
|
/*** Named transport ports stay independent from runtime resource types. */
|
|
41
41
|
function isPort(value) {
|
|
42
42
|
return isInfraShape(value, {
|
|
43
|
-
name: isNonEmptyString,
|
|
44
43
|
port: infraFields.port,
|
|
45
44
|
protocol: (protocol) => protocol === undefined || protocol === 'tcp' || protocol === 'udp',
|
|
46
45
|
publishedPort: infraFields.optionalPort,
|
|
@@ -50,7 +49,7 @@ function isPort(value) {
|
|
|
50
49
|
function hasValidPublishedPorts(workload) {
|
|
51
50
|
if (!isRecord(workload))
|
|
52
51
|
return false;
|
|
53
|
-
const ports =
|
|
52
|
+
const ports = isRecord(workload.ports) ? Object.values(workload.ports) : [];
|
|
54
53
|
const published = ports.flatMap((port) => {
|
|
55
54
|
if (!isRecord(port) || typeof port.publishedPort !== 'number')
|
|
56
55
|
return [];
|
|
@@ -62,9 +61,21 @@ function hasValidPublishedPorts(workload) {
|
|
|
62
61
|
(workload.replicas === undefined ||
|
|
63
62
|
(typeof workload.replicas === 'number' && workload.replicas <= 1)))));
|
|
64
63
|
}
|
|
65
|
-
/***
|
|
66
|
-
function
|
|
67
|
-
return
|
|
64
|
+
/*** Validate portable config/policy files keyed by their absolute container path. */
|
|
65
|
+
function isFileMap(value) {
|
|
66
|
+
return (isRecord(value) &&
|
|
67
|
+
Object.entries(value).every(([filePath, content]) => isAbsoluteWorkloadPath(filePath) && isInfraWorkloadValue(content)));
|
|
68
|
+
}
|
|
69
|
+
/*** Validate persistence volumes by stable ID and keep mount paths unique within one workload. */
|
|
70
|
+
function isVolumeRegistry(value) {
|
|
71
|
+
if (!isRecord(value))
|
|
72
|
+
return false;
|
|
73
|
+
const entries = Object.entries(value);
|
|
74
|
+
if (!entries.every(([volumeId, volume]) => isVolume(volume) && isRecord(volume) && volume.id === volumeId)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const mountPaths = Object.values(value).map((volume) => isRecord(volume) ? volume.mountPath : undefined);
|
|
78
|
+
return new Set(mountPaths).size === mountPaths.length;
|
|
68
79
|
}
|
|
69
80
|
/*** Persistence has explicit ownership-local identity, optional initialization and retention policy. */
|
|
70
81
|
function isVolume(value) {
|
|
@@ -83,9 +94,4 @@ function isAbsoluteWorkloadPath(value) {
|
|
|
83
94
|
value.length > 1 &&
|
|
84
95
|
!value.split('/').includes('..'));
|
|
85
96
|
}
|
|
86
|
-
/*** Duplicate workload-local identities would make runtime projection ambiguous. */
|
|
87
|
-
function hasUniqueField(values, field) {
|
|
88
|
-
const ids = values.map((value) => (isRecord(value) ? Reflect.get(value, field) : undefined));
|
|
89
|
-
return new Set(ids).size === ids.length;
|
|
90
|
-
}
|
|
91
97
|
//# sourceMappingURL=isInfraWorkloadSpec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInfraWorkloadSpec.js","sourceRoot":"","sources":["../../src/infra/isInfraWorkloadSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"isInfraWorkloadSpec.js","sourceRoot":"","sources":["../../src/infra/isInfraWorkloadSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,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AAE,MAAM,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,EAAE,KAAK,QAAQ,CACvF,EACD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACrD,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAChD,CAAC;IACF,OAAO,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,MAAM,CAAC;AACxD,CAAC;AAED,wGAAwG;AACxG,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,YAAY,CAAC,KAAK,EAAE;QACzB,EAAE,EAAE,gBAAgB;QACpB,SAAS,EAAE,sBAAsB;QACjC,OAAO,EAAE,WAAW,CAAC,eAAe;QACpC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,OAAO;QACtD,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,mBAAmB;KACtF,CAAC,CAAC;AACL,CAAC;AAED,mFAAmF;AACnF,SAAS,sBAAsB,CAAC,KAAc;IAC5C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QACrB,KAAK,CAAC,MAAM,GAAG,CAAC;QAChB,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CACjC,CAAC;AACJ,CAAC","sourcesContent":["import { isStringArray } from '@ankhorage/utility/array';\nimport { isRecord } from '@ankhorage/utility/object';\nimport { isNonEmptyString } from '@ankhorage/utility/string';\n\nimport { isSerializableSet } from '../collections';\nimport type { InfraShape } from '../types/infraValidation';\nimport type { InfraWorkloadSpec } from '../types/infraWorkload';\nimport { infraFields } from './infraFields';\nimport { isInfraShape } from './isInfraShape';\nimport { isInfraWorkloadHealth } from './isInfraWorkloadHealth';\nimport { isInfraWorkloadValue } from './isInfraWorkloadValue';\n\n/*** Validate the portable desired workload; runtime-specific fields and plaintext secret objects fail. */\nexport function isInfraWorkloadSpec(value: unknown): value is InfraWorkloadSpec {\n if (\n !isInfraShape(value, {\n id: isNonEmptyString,\n artifact: (artifact) =>\n isInfraShape(artifact, { kind: (kind) => kind === 'image', image: isNonEmptyString }),\n command: infraFields.optionalStrings,\n args: (args) => args === undefined || isStringArray(args),\n ports: (ports) => ports === undefined || isPortRegistry(ports),\n environment: (environment) =>\n environment === undefined ||\n (isRecord(environment) && Object.values(environment).every(isInfraWorkloadValue)),\n files: (files) => files === undefined || isFileMap(files),\n health: (health) => health === undefined || isInfraWorkloadHealth(health),\n resources: (resources) =>\n resources === undefined ||\n isInfraShape(resources, {\n cpuMillis: infraFields.optionalPositiveInteger,\n memoryMiB: infraFields.optionalPositiveInteger,\n }),\n persistence: (volumes) => volumes === undefined || isVolumeRegistry(volumes),\n exposure: (exposure) =>\n exposure === undefined || exposure === 'internal' || exposure === 'public',\n replicas: infraFields.optionalNonnegativeInteger,\n dependsOn: (dependsOn) => dependsOn === undefined || isSerializableSet(dependsOn),\n } satisfies InfraShape<InfraWorkloadSpec>)\n ) {\n return false;\n }\n return hasValidPublishedPorts(value);\n}\n\n/*** Validate named transport ports keyed by their stable authored name. */\nfunction isPortRegistry(value: unknown): boolean {\n return (\n isRecord(value) &&\n Object.entries(value).every(([name, port]) => isNonEmptyString(name) && isPort(port))\n );\n}\n\n/*** Named transport ports stay independent from runtime resource types. */\nfunction isPort(value: unknown): boolean {\n return isInfraShape(value, {\n port: infraFields.port,\n protocol: (protocol) => protocol === undefined || protocol === 'tcp' || protocol === 'udp',\n publishedPort: infraFields.optionalPort,\n });\n}\n\n/*** Require fixed external listeners to belong to one public workload replica. */\nfunction hasValidPublishedPorts(workload: unknown): boolean {\n if (!isRecord(workload)) return false;\n const ports = isRecord(workload.ports) ? Object.values(workload.ports) : [];\n const published = ports.flatMap((port) => {\n if (!isRecord(port) || typeof port.publishedPort !== 'number') return [];\n return [port.publishedPort];\n });\n return (\n new Set(published).size === published.length &&\n (published.length === 0 ||\n (workload.exposure === 'public' &&\n (workload.replicas === undefined ||\n (typeof workload.replicas === 'number' && workload.replicas <= 1))))\n );\n}\n\n/*** Validate portable config/policy files keyed by their absolute container path. */\nfunction isFileMap(value: unknown): boolean {\n return (\n isRecord(value) &&\n Object.entries(value).every(\n ([filePath, content]) => isAbsoluteWorkloadPath(filePath) && isInfraWorkloadValue(content),\n )\n );\n}\n\n/*** Validate persistence volumes by stable ID and keep mount paths unique within one workload. */\nfunction isVolumeRegistry(value: unknown): boolean {\n if (!isRecord(value)) return false;\n const entries = Object.entries(value);\n if (\n !entries.every(\n ([volumeId, volume]) => isVolume(volume) && isRecord(volume) && volume.id === volumeId,\n )\n ) {\n return false;\n }\n const mountPaths = Object.values(value).map((volume) =>\n isRecord(volume) ? volume.mountPath : undefined,\n );\n return new Set(mountPaths).size === mountPaths.length;\n}\n\n/*** Persistence has explicit ownership-local identity, optional initialization and retention policy. */\nfunction isVolume(value: unknown): boolean {\n return isInfraShape(value, {\n id: isNonEmptyString,\n mountPath: isAbsoluteWorkloadPath,\n sizeGiB: infraFields.positiveInteger,\n seed: (seed) => seed === undefined || seed === 'image',\n retention: (retention) => retention === 'retain' || retention === 'delete-on-destroy',\n });\n}\n\n/*** Workload paths are absolute container paths, never relative host traversal. */\nfunction isAbsoluteWorkloadPath(value: unknown): boolean {\n return (\n typeof value === 'string' &&\n value.startsWith('/') &&\n value.length > 1 &&\n !value.split('/').includes('..')\n );\n}\n"]}
|
package/dist/requirements.d.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
+
import type { SerializableSet } from './collections';
|
|
1
2
|
export declare const ANKHORAGE_PERMISSION_NAMES: readonly ["camera", "microphone", "mediaLibrary", "mediaLibraryWrite", "locationForeground", "locationBackground", "notifications", "clipboard"];
|
|
2
3
|
export type AnkhoragePermissionName = (typeof ANKHORAGE_PERMISSION_NAMES)[number];
|
|
3
4
|
export declare const ANKHORAGE_CAPABILITY_NAMES: readonly ["barcodeScanner", "cameraPreview", "ebookReader", "mediaPicker", "filePicker", "location", "notifications", "clipboard"];
|
|
4
5
|
export type AnkhorageCapabilityName = (typeof ANKHORAGE_CAPABILITY_NAMES)[number];
|
|
5
|
-
export interface ScreenPermissionRequirement {
|
|
6
|
-
readonly permission: AnkhoragePermissionName;
|
|
7
|
-
}
|
|
8
|
-
export interface ScreenCapabilityRequirement {
|
|
9
|
-
readonly capability: AnkhorageCapabilityName;
|
|
10
|
-
}
|
|
11
6
|
export interface ScreenRequirements {
|
|
12
|
-
readonly permissions?:
|
|
13
|
-
readonly capabilities?:
|
|
7
|
+
readonly permissions?: SerializableSet<AnkhoragePermissionName>;
|
|
8
|
+
readonly capabilities?: SerializableSet<AnkhorageCapabilityName>;
|
|
14
9
|
}
|
|
15
10
|
export interface ComponentRequirements {
|
|
16
|
-
readonly permissions?:
|
|
17
|
-
readonly capabilities?:
|
|
11
|
+
readonly permissions?: SerializableSet<AnkhoragePermissionName>;
|
|
12
|
+
readonly capabilities?: SerializableSet<AnkhorageCapabilityName>;
|
|
18
13
|
}
|
|
19
14
|
//# sourceMappingURL=requirements.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requirements.d.ts","sourceRoot":"","sources":["../src/requirements.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,kJAS7B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAElF,eAAO,MAAM,0BAA0B,oIAS7B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAElF,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"requirements.d.ts","sourceRoot":"","sources":["../src/requirements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,eAAO,MAAM,0BAA0B,kJAS7B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAElF,eAAO,MAAM,0BAA0B,oIAS7B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAElF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,uBAAuB,CAAC,CAAC;IAChE,QAAQ,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC,uBAAuB,CAAC,CAAC;CAClE;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,uBAAuB,CAAC,CAAC;IAChE,QAAQ,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC,uBAAuB,CAAC,CAAC;CAClE"}
|
package/dist/requirements.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requirements.js","sourceRoot":"","sources":["../src/requirements.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"requirements.js","sourceRoot":"","sources":["../src/requirements.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,QAAQ;IACR,YAAY;IACZ,cAAc;IACd,mBAAmB;IACnB,oBAAoB;IACpB,oBAAoB;IACpB,eAAe;IACf,WAAW;CACH,CAAC;AAIX,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,aAAa;IACb,YAAY;IACZ,UAAU;IACV,eAAe;IACf,WAAW;CACH,CAAC","sourcesContent":["import type { SerializableSet } from './collections';\n\nexport const ANKHORAGE_PERMISSION_NAMES = [\n 'camera',\n 'microphone',\n 'mediaLibrary',\n 'mediaLibraryWrite',\n 'locationForeground',\n 'locationBackground',\n 'notifications',\n 'clipboard',\n] as const;\n\nexport type AnkhoragePermissionName = (typeof ANKHORAGE_PERMISSION_NAMES)[number];\n\nexport const ANKHORAGE_CAPABILITY_NAMES = [\n 'barcodeScanner',\n 'cameraPreview',\n 'ebookReader',\n 'mediaPicker',\n 'filePicker',\n 'location',\n 'notifications',\n 'clipboard',\n] as const;\n\nexport type AnkhorageCapabilityName = (typeof ANKHORAGE_CAPABILITY_NAMES)[number];\n\nexport interface ScreenRequirements {\n readonly permissions?: SerializableSet<AnkhoragePermissionName>;\n readonly capabilities?: SerializableSet<AnkhorageCapabilityName>;\n}\n\nexport interface ComponentRequirements {\n readonly permissions?: SerializableSet<AnkhoragePermissionName>;\n readonly capabilities?: SerializableSet<AnkhorageCapabilityName>;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type SerializableValue = string | number | boolean | null | readonly SerializableValue[] | {
|
|
2
|
+
readonly [key: string]: SerializableValue;
|
|
3
|
+
};
|
|
4
|
+
/*** Validate recursively serializable manifest/config values without accepting functions or host objects. */
|
|
5
|
+
export declare function isSerializableValue(value: unknown): value is SerializableValue;
|
|
6
|
+
//# sourceMappingURL=serializable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializable.d.ts","sourceRoot":"","sources":["../src/serializable.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,iBAAiB,EAAE,GAC5B;IACE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAC;CAC3C,CAAC;AAEN,6GAA6G;AAC7G,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAW9E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isRecord } from '@ankhorage/utility/object';
|
|
2
|
+
/*** Validate recursively serializable manifest/config values without accepting functions or host objects. */
|
|
3
|
+
export function isSerializableValue(value) {
|
|
4
|
+
if (value === null ||
|
|
5
|
+
typeof value === 'string' ||
|
|
6
|
+
typeof value === 'number' ||
|
|
7
|
+
typeof value === 'boolean') {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (Array.isArray(value))
|
|
11
|
+
return value.every(isSerializableValue);
|
|
12
|
+
return isRecord(value) && Object.values(value).every(isSerializableValue);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=serializable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializable.js","sourceRoot":"","sources":["../src/serializable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAYrD,6GAA6G;AAC7G,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,IACE,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS,EAC1B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAClE,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import { isRecord } from '@ankhorage/utility/object';\n\nexport type SerializableValue =\n | string\n | number\n | boolean\n | null\n | readonly SerializableValue[]\n | {\n readonly [key: string]: SerializableValue;\n };\n\n/*** Validate recursively serializable manifest/config values without accepting functions or host objects. */\nexport function isSerializableValue(value: unknown): value is SerializableValue {\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n return true;\n }\n if (Array.isArray(value)) return value.every(isSerializableValue);\n return isRecord(value) && Object.values(value).every(isSerializableValue);\n}\n"]}
|
package/dist/state.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import type { SerializableValue } from './serializable';
|
|
1
2
|
/** Legend currently implements in-memory state only; unsupported persistence cannot be selected. */
|
|
2
3
|
export interface AppStateSpec {
|
|
3
4
|
readonly provider: 'legend';
|
|
4
5
|
readonly persistence?: false;
|
|
5
6
|
}
|
|
6
7
|
export type StatePrimitive = string | number | boolean | null;
|
|
7
|
-
export type StateValue =
|
|
8
|
-
readonly [key: string]: StateValue;
|
|
9
|
-
};
|
|
8
|
+
export type StateValue = SerializableValue;
|
|
10
9
|
export type StatePath = string | readonly string[];
|
|
11
10
|
export interface StateAdapterCapabilities {
|
|
12
11
|
readonly subscriptions: boolean;
|
package/dist/state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;CAC9B;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE9D,MAAM,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,oGAAoG;AACpG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ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C,MAAM,SAAS,UAAU,GAAG,UAAU,IAAI,CAClE,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,KAC5B,IAAI,CAAC;AAEV,MAAM,WAAW,iBAAiB;IAChC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,YAAY,EAAE,wBAAwB,CAAC;IAEhD,GAAG,CAAC,MAAM,SAAS,UAAU,GAAG,UAAU,EAAE,IAAI,EAAE,SAAS,GAAG,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC9F,GAAG,CAAC,MAAM,SAAS,UAAU,GAAG,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC;IACzF,SAAS,CAAC,MAAM,SAAS,UAAU,GAAG,UAAU,EAC9C,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,GAC9B,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAClC,MAAM,CAAC,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,CAAC;CACvC"}
|
package/dist/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"","sourcesContent":["/** Legend currently implements in-memory state only; unsupported persistence cannot be selected. */\nexport interface AppStateSpec {\n readonly provider: 'legend';\n readonly persistence?: false;\n}\n\nexport type StatePrimitive = string | number | boolean | null;\n\nexport type StateValue
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"","sourcesContent":["import type { SerializableValue } from './serializable';\n\n/** Legend currently implements in-memory state only; unsupported persistence cannot be selected. */\nexport interface AppStateSpec {\n readonly provider: 'legend';\n readonly persistence?: false;\n}\n\nexport type StatePrimitive = string | number | boolean | null;\n\nexport type StateValue = SerializableValue;\n\nexport type StatePath = string | readonly string[];\n\nexport interface StateAdapterCapabilities {\n readonly subscriptions: boolean;\n readonly computed: boolean;\n readonly persistence: boolean;\n}\n\nexport interface StateAdapterError {\n readonly code: string;\n readonly message: string;\n readonly cause?: unknown;\n}\n\nexport type StateSuccess<TValue = void> = [TValue] extends [void]\n ? {\n readonly ok: true;\n }\n : {\n readonly ok: true;\n readonly data: TValue;\n };\n\nexport type StateResult<TValue = void> =\n | StateSuccess<TValue>\n | {\n readonly ok: false;\n readonly error: StateAdapterError;\n };\n\nexport interface StateSnapshot<TValue extends StateValue = StateValue> {\n readonly path: StatePath;\n readonly value: TValue | undefined;\n}\n\nexport type StateListener<TValue extends StateValue = StateValue> = (\n snapshot: StateSnapshot<TValue>,\n) => void;\n\nexport interface StateSubscription {\n unsubscribe(): Promise<void> | void;\n}\n\nexport interface StateAdapter {\n readonly capabilities: StateAdapterCapabilities;\n\n get<TValue extends StateValue = StateValue>(path: StatePath): StateResult<TValue | undefined>;\n set<TValue extends StateValue = StateValue>(path: StatePath, value: TValue): StateResult;\n subscribe<TValue extends StateValue = StateValue>(\n path: StatePath,\n listener: StateListener<TValue>,\n ): StateResult<StateSubscription>;\n delete?(path: StatePath): StateResult;\n}\n"]}
|