@ankhorage/contracts 19.0.0 → 19.2.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 +12 -0
- package/README.md +1 -1
- package/dist/deployProvider.d.ts +5 -0
- package/dist/deployProvider.d.ts.map +1 -0
- package/dist/deployProvider.js +5 -0
- package/dist/deployProvider.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/infra/infraFields.d.ts +1 -0
- package/dist/infra/infraFields.d.ts.map +1 -1
- package/dist/infra/infraFields.js +2 -0
- package/dist/infra/infraFields.js.map +1 -1
- package/dist/infra/isInfraEnvironmentSpec.d.ts.map +1 -1
- package/dist/infra/isInfraEnvironmentSpec.js +6 -1
- package/dist/infra/isInfraEnvironmentSpec.js.map +1 -1
- package/dist/infra/isInfraWorkloadSpec.d.ts.map +1 -1
- package/dist/infra/isInfraWorkloadSpec.js +22 -2
- package/dist/infra/isInfraWorkloadSpec.js.map +1 -1
- package/dist/types/deployMonetization.d.ts +78 -0
- package/dist/types/deployMonetization.d.ts.map +1 -0
- package/dist/types/deployMonetization.js +2 -0
- package/dist/types/deployMonetization.js.map +1 -0
- package/dist/types/deployProvider.d.ts +266 -0
- package/dist/types/deployProvider.d.ts.map +1 -0
- package/dist/types/deployProvider.js +21 -0
- package/dist/types/deployProvider.js.map +1 -0
- package/dist/types/deployRelease.d.ts +128 -0
- package/dist/types/deployRelease.d.ts.map +1 -0
- package/dist/types/deployRelease.js +2 -0
- package/dist/types/deployRelease.js.map +1 -0
- package/dist/types/deployStoreListing.d.ts +91 -0
- package/dist/types/deployStoreListing.d.ts.map +1 -0
- package/dist/types/deployStoreListing.js +2 -0
- package/dist/types/deployStoreListing.js.map +1 -0
- package/dist/types/infraWorkload.d.ts +2 -0
- package/dist/types/infraWorkload.d.ts.map +1 -1
- package/dist/types/infraWorkload.js.map +1 -1
- package/package.json +5 -1
- package/src/deployProvider.test.ts +82 -0
- package/src/deployProvider.ts +4 -0
- package/src/index.ts +1 -0
- package/src/infra/infraFields.ts +3 -0
- package/src/infra/isInfraEnvironmentSpec.ts +13 -1
- package/src/infra/isInfraWorkloadSpec.ts +56 -33
- package/src/infra-published-port.test.ts +43 -0
- package/src/infra-workload.test.ts +1 -1
- package/src/types/deployMonetization.ts +106 -0
- package/src/types/deployProvider.ts +338 -0
- package/src/types/deployRelease.ts +153 -0
- package/src/types/deployStoreListing.ts +125 -0
- package/src/types/infraWorkload.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ankhorage/contracts
|
|
2
2
|
|
|
3
|
+
## 19.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8644f9c: Add portable deployment provider contracts for provider registration, native builds, store delivery, listings, monetization, and releases.
|
|
8
|
+
|
|
9
|
+
## 19.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 95ed577: add fixed published ports for public workloads
|
|
14
|
+
|
|
3
15
|
## 19.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# @ankhorage/contracts
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Serializable app, action, theme, auth, and secret-store contracts for Ankhorage.
|
|
9
9
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployProvider.d.ts","sourceRoot":"","sources":["../src/deployProvider.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployProvider.js","sourceRoot":"","sources":["../src/deployProvider.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC","sourcesContent":["export * from './types/deployMonetization';\nexport * from './types/deployProvider';\nexport * from './types/deployRelease';\nexport * from './types/deployStoreListing';\n"]}
|
package/dist/index.d.ts
CHANGED
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,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,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"}
|
package/dist/index.js
CHANGED
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,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 './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,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"]}
|
|
@@ -8,5 +8,6 @@ export declare const infraFields: {
|
|
|
8
8
|
optionalPositiveInteger: (value: unknown) => boolean;
|
|
9
9
|
optionalNonnegativeInteger: (value: unknown) => boolean;
|
|
10
10
|
port: (value: unknown) => boolean;
|
|
11
|
+
optionalPort: (value: unknown) => boolean;
|
|
11
12
|
};
|
|
12
13
|
//# sourceMappingURL=infraFields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infraFields.d.ts","sourceRoot":"","sources":["../../src/infra/infraFields.ts"],"names":[],"mappings":"AAGA,qGAAqG;AACrG,eAAO,MAAM,WAAW;0BACA,OAAO,KAAG,OAAO;qBACtB,OAAO,KAAG,OAAO;6BACT,OAAO,KAAG,OAAO;6BAEjB,OAAO,KAAG,OAAO;gCAEd,OAAO,KAAG,OAAO;qCAEZ,OAAO,KAAG,OAAO;wCAEd,OAAO,KAAG,OAAO;kBAEvC,OAAO,KAAG,OAAO;
|
|
1
|
+
{"version":3,"file":"infraFields.d.ts","sourceRoot":"","sources":["../../src/infra/infraFields.ts"],"names":[],"mappings":"AAGA,qGAAqG;AACrG,eAAO,MAAM,WAAW;0BACA,OAAO,KAAG,OAAO;qBACtB,OAAO,KAAG,OAAO;6BACT,OAAO,KAAG,OAAO;6BAEjB,OAAO,KAAG,OAAO;gCAEd,OAAO,KAAG,OAAO;qCAEZ,OAAO,KAAG,OAAO;wCAEd,OAAO,KAAG,OAAO;kBAEvC,OAAO,KAAG,OAAO;0BAET,OAAO,KAAG,OAAO;CAGxC,CAAC"}
|
|
@@ -10,5 +10,7 @@ export const infraFields = {
|
|
|
10
10
|
optionalPositiveInteger: (value) => value === undefined || (typeof value === 'number' && Number.isSafeInteger(value) && value > 0),
|
|
11
11
|
optionalNonnegativeInteger: (value) => value === undefined || (typeof value === 'number' && Number.isSafeInteger(value) && value >= 0),
|
|
12
12
|
port: (value) => typeof value === 'number' && Number.isInteger(value) && value > 0 && value <= 65535,
|
|
13
|
+
optionalPort: (value) => value === undefined ||
|
|
14
|
+
(typeof value === 'number' && Number.isInteger(value) && value > 0 && value <= 65535),
|
|
13
15
|
};
|
|
14
16
|
//# sourceMappingURL=infraFields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infraFields.js","sourceRoot":"","sources":["../../src/infra/infraFields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,qGAAqG;AACrG,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,YAAY,EAAE,CAAC,KAAc,EAAW,EAAE,CAAC,KAAK,KAAK,SAAS,IAAI,gBAAgB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KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK;IACrF,YAAY,EAAE,CAAC,KAAc,EAAW,EAAE,CACxC,KAAK,KAAK,SAAS;QACnB,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC;CACxF,CAAC","sourcesContent":["import { isStringArray } from '@ankhorage/utility/array';\nimport { isNonEmptyString } from '@ankhorage/utility/string';\n\n/*** Primitive field rules for portable Infra configuration, shared by its exact-shape validators. */\nexport const infraFields = {\n optionalText: (value: unknown): boolean => value === undefined || isNonEmptyString(value),\n strings: (value: unknown): boolean => isStringArray(value) && value.every(isNonEmptyString),\n optionalStrings: (value: unknown): boolean =>\n value === undefined || (isStringArray(value) && value.every(isNonEmptyString)),\n positiveInteger: (value: unknown): boolean =>\n typeof value === 'number' && Number.isSafeInteger(value) && value > 0,\n nonnegativeInteger: (value: unknown): boolean =>\n typeof value === 'number' && Number.isSafeInteger(value) && value >= 0,\n optionalPositiveInteger: (value: unknown): boolean =>\n value === undefined || (typeof value === 'number' && Number.isSafeInteger(value) && value > 0),\n optionalNonnegativeInteger: (value: unknown): boolean =>\n value === undefined || (typeof value === 'number' && Number.isSafeInteger(value) && value >= 0),\n port: (value: unknown): boolean =>\n typeof value === 'number' && Number.isInteger(value) && value > 0 && value <= 65535,\n optionalPort: (value: unknown): boolean =>\n value === undefined ||\n (typeof value === 'number' && Number.isInteger(value) && value > 0 && value <= 65535),\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInfraEnvironmentSpec.d.ts","sourceRoot":"","sources":["../../src/infra/isInfraEnvironmentSpec.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAA0B,MAAM,wBAAwB,CAAC;AAU3F,8FAA8F;AAC9F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,
|
|
1
|
+
{"version":3,"file":"isInfraEnvironmentSpec.d.ts","sourceRoot":"","sources":["../../src/infra/isInfraEnvironmentSpec.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAA0B,MAAM,wBAAwB,CAAC;AAU3F,8FAA8F;AAC9F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAIpF"}
|
|
@@ -9,7 +9,7 @@ import { isInfraShape } from './isInfraShape';
|
|
|
9
9
|
import { isInfraWorkloadSpec } from './isInfraWorkloadSpec';
|
|
10
10
|
/*** Validate sibling capabilities and their required relationships within one environment. */
|
|
11
11
|
export function isInfraEnvironmentSpec(value) {
|
|
12
|
-
return isEnvironmentShape(value) && hasServiceDependencies(value);
|
|
12
|
+
return (isEnvironmentShape(value) && hasServiceDependencies(value) && hasUniquePublishedPorts(value));
|
|
13
13
|
}
|
|
14
14
|
/*** Check all environment field shapes before inspecting canonical dependency metadata. */
|
|
15
15
|
function isEnvironmentShape(value) {
|
|
@@ -86,6 +86,11 @@ function isWorkloads(value) {
|
|
|
86
86
|
value.every(isInfraWorkloadSpec) &&
|
|
87
87
|
new Set(value.map((workload) => workload.id)).size === value.length);
|
|
88
88
|
}
|
|
89
|
+
/*** Prevent two workloads in one environment from claiming the same external listener. */
|
|
90
|
+
function hasUniquePublishedPorts(value) {
|
|
91
|
+
const ports = (value.workloads ?? []).flatMap((workload) => (workload.ports ?? []).flatMap(({ publishedPort }) => publishedPort === undefined ? [] : [publishedPort]));
|
|
92
|
+
return new Set(ports).size === ports.length;
|
|
93
|
+
}
|
|
89
94
|
/*** Check catalog dependencies against selected sibling capabilities and runtime capabilities. */
|
|
90
95
|
function hasServiceDependencies(value) {
|
|
91
96
|
const selections = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInfraEnvironmentSpec.js","sourceRoot":"","sources":["../../src/infra/isInfraEnvironmentSpec.ts"],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AC,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 { InfraEnvironmentSpec, InfraObjectStorageSpec } 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 isEnvironmentShape(value) && hasServiceDependencies(value);\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 }),\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 }),\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/*** 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/*** 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') return isInfraShape(value, common);\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/*** 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;AAI7D,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,C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AM,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 { InfraEnvironmentSpec, InfraObjectStorageSpec } 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) && hasServiceDependencies(value) && 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 }),\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 }),\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/*** 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/*** 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') return isInfraShape(value, common);\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInfraWorkloadSpec.d.ts","sourceRoot":"","sources":["../../src/infra/isInfraWorkloadSpec.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAMhE,0GAA0G;AAC1G,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,
|
|
1
|
+
{"version":3,"file":"isInfraWorkloadSpec.d.ts","sourceRoot":"","sources":["../../src/infra/isInfraWorkloadSpec.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAMhE,0GAA0G;AAC1G,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAuC9E"}
|
|
@@ -7,7 +7,7 @@ import { isInfraWorkloadHealth } from './isInfraWorkloadHealth';
|
|
|
7
7
|
import { isInfraWorkloadValue } from './isInfraWorkloadValue';
|
|
8
8
|
/*** Validate the portable desired workload; runtime-specific fields and plaintext secret objects fail. */
|
|
9
9
|
export function isInfraWorkloadSpec(value) {
|
|
10
|
-
|
|
10
|
+
if (!isInfraShape(value, {
|
|
11
11
|
id: isNonEmptyString,
|
|
12
12
|
artifact: (artifact) => isInfraShape(artifact, { kind: (kind) => kind === 'image', image: isNonEmptyString }),
|
|
13
13
|
command: infraFields.optionalStrings,
|
|
@@ -32,7 +32,10 @@ export function isInfraWorkloadSpec(value) {
|
|
|
32
32
|
exposure: (exposure) => exposure === undefined || exposure === 'internal' || exposure === 'public',
|
|
33
33
|
replicas: infraFields.optionalNonnegativeInteger,
|
|
34
34
|
dependsOn: infraFields.optionalStrings,
|
|
35
|
-
})
|
|
35
|
+
})) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return hasValidPublishedPorts(value);
|
|
36
39
|
}
|
|
37
40
|
/*** Named transport ports stay independent from runtime resource types. */
|
|
38
41
|
function isPort(value) {
|
|
@@ -40,7 +43,24 @@ function isPort(value) {
|
|
|
40
43
|
name: isNonEmptyString,
|
|
41
44
|
port: infraFields.port,
|
|
42
45
|
protocol: (protocol) => protocol === undefined || protocol === 'tcp' || protocol === 'udp',
|
|
46
|
+
publishedPort: infraFields.optionalPort,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/*** Require fixed external listeners to belong to one public workload replica. */
|
|
50
|
+
function hasValidPublishedPorts(workload) {
|
|
51
|
+
if (!isRecord(workload))
|
|
52
|
+
return false;
|
|
53
|
+
const ports = Array.isArray(workload.ports) ? workload.ports : [];
|
|
54
|
+
const published = ports.flatMap((port) => {
|
|
55
|
+
if (!isRecord(port) || typeof port.publishedPort !== 'number')
|
|
56
|
+
return [];
|
|
57
|
+
return [port.publishedPort];
|
|
43
58
|
});
|
|
59
|
+
return (new Set(published).size === published.length &&
|
|
60
|
+
(published.length === 0 ||
|
|
61
|
+
(workload.exposure === 'public' &&
|
|
62
|
+
(workload.replicas === undefined ||
|
|
63
|
+
(typeof workload.replicas === 'number' && workload.replicas <= 1)))));
|
|
44
64
|
}
|
|
45
65
|
/*** Portable files model policy/config materialization without host filesystem access. */
|
|
46
66
|
function isFile(value) {
|
|
@@ -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;AAI7D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,0GAA0G;AAC1G,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,
|
|
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;AAI7D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,qBAAq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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;AAED,oFAAoF;AACpF,SAAS,cAAc,CAAC,MAA0B,EAAE,KAAa;IAC/D,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7F,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,MAAM,CAAC;AAC1C,CAAC","sourcesContent":["import { isStringArray } from '@ankhorage/utility/array';\nimport { isRecord } from '@ankhorage/utility/object';\nimport { isNonEmptyString } from '@ankhorage/utility/string';\n\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) =>\n ports === undefined ||\n (Array.isArray(ports) && ports.every(isPort) && hasUniqueField(ports, 'name')),\n environment: (environment) =>\n environment === undefined ||\n (isRecord(environment) && Object.values(environment).every(isInfraWorkloadValue)),\n files: (files) =>\n files === undefined ||\n (Array.isArray(files) && files.every(isFile) && hasUniqueField(files, 'path')),\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) =>\n volumes === undefined ||\n (Array.isArray(volumes) &&\n volumes.every(isVolume) &&\n hasUniqueField(volumes, 'id') &&\n hasUniqueField(volumes, 'mountPath')),\n exposure: (exposure) =>\n exposure === undefined || exposure === 'internal' || exposure === 'public',\n replicas: infraFields.optionalNonnegativeInteger,\n dependsOn: infraFields.optionalStrings,\n } satisfies InfraShape<InfraWorkloadSpec>)\n ) {\n return false;\n }\n return hasValidPublishedPorts(value);\n}\n\n/*** Named transport ports stay independent from runtime resource types. */\nfunction isPort(value: unknown): boolean {\n return isInfraShape(value, {\n name: isNonEmptyString,\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 = Array.isArray(workload.ports) ? 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/*** Portable files model policy/config materialization without host filesystem access. */\nfunction isFile(value: unknown): boolean {\n return isInfraShape(value, { path: isAbsoluteWorkloadPath, content: isInfraWorkloadValue });\n}\n\n/*** Persistence has explicit ownership-local identity and a retention policy. */\nfunction isVolume(value: unknown): boolean {\n return isInfraShape(value, {\n id: isNonEmptyString,\n mountPath: isAbsoluteWorkloadPath,\n sizeGiB: infraFields.positiveInteger,\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\n/*** Duplicate workload-local identities would make runtime projection ambiguous. */\nfunction hasUniqueField(values: readonly unknown[], field: string): boolean {\n const ids = values.map((value) => (isRecord(value) ? Reflect.get(value, field) : undefined));\n return new Set(ids).size === ids.length;\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { DeploymentCredentialReference, DeploymentProviderResult, DeploymentSecretResolver, DeploymentStoreIdentity } from './deployProvider';
|
|
2
|
+
export type MonetizationProductKind = 'consumable' | 'non-consumable' | 'subscription';
|
|
3
|
+
export interface MonetizationLocalization {
|
|
4
|
+
readonly locale: string;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
}
|
|
8
|
+
export interface MonetizationBasePrice {
|
|
9
|
+
readonly country: string;
|
|
10
|
+
readonly currency: string;
|
|
11
|
+
readonly amount: string;
|
|
12
|
+
}
|
|
13
|
+
export type MonetizationSubscriptionPeriod = 'P1W' | 'P1M' | 'P2M' | 'P3M' | 'P6M' | 'P1Y';
|
|
14
|
+
export interface MonetizationSubscription {
|
|
15
|
+
readonly family: string;
|
|
16
|
+
readonly period: MonetizationSubscriptionPeriod;
|
|
17
|
+
readonly level?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface MonetizationProduct {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly kind: MonetizationProductKind;
|
|
22
|
+
readonly localizations: readonly MonetizationLocalization[];
|
|
23
|
+
readonly basePrice: MonetizationBasePrice;
|
|
24
|
+
readonly subscription?: MonetizationSubscription;
|
|
25
|
+
}
|
|
26
|
+
export interface MonetizationObservedProduct {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly kind: MonetizationProductKind | 'one-time';
|
|
29
|
+
readonly localizations: readonly MonetizationLocalization[];
|
|
30
|
+
readonly basePrice?: MonetizationBasePrice;
|
|
31
|
+
readonly subscription?: MonetizationSubscription;
|
|
32
|
+
}
|
|
33
|
+
export interface MonetizationDesiredState {
|
|
34
|
+
readonly revision: string;
|
|
35
|
+
readonly products: readonly MonetizationProduct[];
|
|
36
|
+
}
|
|
37
|
+
export interface MonetizationDiagnostic {
|
|
38
|
+
readonly severity: 'warning' | 'error';
|
|
39
|
+
readonly code: string;
|
|
40
|
+
readonly message: string;
|
|
41
|
+
readonly target?: 'android' | 'ios';
|
|
42
|
+
readonly productId?: string;
|
|
43
|
+
readonly locale?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface MonetizationTargetState {
|
|
46
|
+
readonly target: 'android' | 'ios';
|
|
47
|
+
readonly products: readonly MonetizationObservedProduct[];
|
|
48
|
+
readonly subscriptionFamilies: readonly string[];
|
|
49
|
+
readonly diagnostics: readonly MonetizationDiagnostic[];
|
|
50
|
+
}
|
|
51
|
+
export interface MonetizationPlanStep {
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly target: 'android' | 'ios';
|
|
54
|
+
readonly productId: string;
|
|
55
|
+
readonly operation: 'ensure-subscription-family' | 'create-product' | 'update-metadata' | 'update-price' | 'update-subscription';
|
|
56
|
+
}
|
|
57
|
+
export interface MonetizationPlan {
|
|
58
|
+
readonly status: 'no-change' | 'changes' | 'blocked';
|
|
59
|
+
readonly desiredRevision: string;
|
|
60
|
+
readonly currentRevision: string;
|
|
61
|
+
readonly steps: readonly MonetizationPlanStep[];
|
|
62
|
+
readonly diagnostics: readonly MonetizationDiagnostic[];
|
|
63
|
+
}
|
|
64
|
+
export interface MonetizationAdapterContext {
|
|
65
|
+
readonly identity: DeploymentStoreIdentity;
|
|
66
|
+
readonly credentials: readonly DeploymentCredentialReference[];
|
|
67
|
+
readonly resolveSecret: DeploymentSecretResolver;
|
|
68
|
+
}
|
|
69
|
+
export interface MonetizationSyncRequest extends MonetizationAdapterContext {
|
|
70
|
+
readonly desired: MonetizationDesiredState;
|
|
71
|
+
readonly plan: MonetizationPlan;
|
|
72
|
+
}
|
|
73
|
+
export interface DeploymentMonetizationAdapter {
|
|
74
|
+
readonly target: 'android' | 'ios';
|
|
75
|
+
inspectAsync(context: MonetizationAdapterContext): Promise<DeploymentProviderResult<MonetizationTargetState>>;
|
|
76
|
+
syncAsync(request: MonetizationSyncRequest): Promise<DeploymentProviderResult<MonetizationTargetState>>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=deployMonetization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployMonetization.d.ts","sourceRoot":"","sources":["../../src/types/deployMonetization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,uBAAuB,GAAG,YAAY,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAEvF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,8BAA8B,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAE3F,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,8BAA8B,CAAC;IAChD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EAAE,uBAAuB,GAC/B,OAAO,CAAC,wBAAwB,CAAC,uBAAuB,CAAC,CAAC,CAAC;CAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployMonetization.js","sourceRoot":"","sources":["../../src/types/deployMonetization.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n DeploymentCredentialReference,\n DeploymentProviderResult,\n DeploymentSecretResolver,\n DeploymentStoreIdentity,\n} from './deployProvider';\n\nexport type MonetizationProductKind = 'consumable' | 'non-consumable' | 'subscription';\n\nexport interface MonetizationLocalization {\n readonly locale: string;\n readonly name: string;\n readonly description: string;\n}\n\nexport interface MonetizationBasePrice {\n readonly country: string;\n readonly currency: string;\n readonly amount: string;\n}\n\nexport type MonetizationSubscriptionPeriod = 'P1W' | 'P1M' | 'P2M' | 'P3M' | 'P6M' | 'P1Y';\n\nexport interface MonetizationSubscription {\n readonly family: string;\n readonly period: MonetizationSubscriptionPeriod;\n readonly level?: number;\n}\n\nexport interface MonetizationProduct {\n readonly id: string;\n readonly kind: MonetizationProductKind;\n readonly localizations: readonly MonetizationLocalization[];\n readonly basePrice: MonetizationBasePrice;\n readonly subscription?: MonetizationSubscription;\n}\n\nexport interface MonetizationObservedProduct {\n readonly id: string;\n readonly kind: MonetizationProductKind | 'one-time';\n readonly localizations: readonly MonetizationLocalization[];\n readonly basePrice?: MonetizationBasePrice;\n readonly subscription?: MonetizationSubscription;\n}\n\nexport interface MonetizationDesiredState {\n readonly revision: string;\n readonly products: readonly MonetizationProduct[];\n}\n\nexport interface MonetizationDiagnostic {\n readonly severity: 'warning' | 'error';\n readonly code: string;\n readonly message: string;\n readonly target?: 'android' | 'ios';\n readonly productId?: string;\n readonly locale?: string;\n}\n\nexport interface MonetizationTargetState {\n readonly target: 'android' | 'ios';\n readonly products: readonly MonetizationObservedProduct[];\n readonly subscriptionFamilies: readonly string[];\n readonly diagnostics: readonly MonetizationDiagnostic[];\n}\n\nexport interface MonetizationPlanStep {\n readonly id: string;\n readonly target: 'android' | 'ios';\n readonly productId: string;\n readonly operation:\n | 'ensure-subscription-family'\n | 'create-product'\n | 'update-metadata'\n | 'update-price'\n | 'update-subscription';\n}\n\nexport interface MonetizationPlan {\n readonly status: 'no-change' | 'changes' | 'blocked';\n readonly desiredRevision: string;\n readonly currentRevision: string;\n readonly steps: readonly MonetizationPlanStep[];\n readonly diagnostics: readonly MonetizationDiagnostic[];\n}\n\nexport interface MonetizationAdapterContext {\n readonly identity: DeploymentStoreIdentity;\n readonly credentials: readonly DeploymentCredentialReference[];\n readonly resolveSecret: DeploymentSecretResolver;\n}\n\nexport interface MonetizationSyncRequest extends MonetizationAdapterContext {\n readonly desired: MonetizationDesiredState;\n readonly plan: MonetizationPlan;\n}\n\nexport interface DeploymentMonetizationAdapter {\n readonly target: 'android' | 'ios';\n inspectAsync(\n context: MonetizationAdapterContext,\n ): Promise<DeploymentProviderResult<MonetizationTargetState>>;\n syncAsync(\n request: MonetizationSyncRequest,\n ): Promise<DeploymentProviderResult<MonetizationTargetState>>;\n}\n"]}
|