@platforma-sdk/package-builder-lib 1.1.0 → 1.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/dist/core/archive.cjs +3 -3
- package/dist/core/archive.cjs.map +1 -1
- package/dist/core/archive.js.map +1 -1
- package/dist/core/conda/builder.cjs +9 -4
- package/dist/core/conda/builder.cjs.map +1 -1
- package/dist/core/conda/builder.js +5 -1
- package/dist/core/conda/builder.js.map +1 -1
- package/dist/core/conda/validate-spec.cjs +2 -2
- package/dist/core/conda/validate-spec.cjs.map +1 -1
- package/dist/core/conda/validate-spec.js.map +1 -1
- package/dist/core/core.cjs +29 -8
- package/dist/core/core.cjs.map +1 -1
- package/dist/core/core.d.ts +6 -1
- package/dist/core/core.d.ts.map +1 -1
- package/dist/core/core.js +27 -6
- package/dist/core/core.js.map +1 -1
- package/dist/core/docker-conda.cjs +2 -2
- package/dist/core/docker-conda.cjs.map +1 -1
- package/dist/core/docker-conda.js.map +1 -1
- package/dist/core/docker-python.cjs +3 -2
- package/dist/core/docker-python.cjs.map +1 -1
- package/dist/core/docker-python.js +1 -1
- package/dist/core/docker-python.js.map +1 -1
- package/dist/core/docker.cjs +3 -3
- package/dist/core/docker.cjs.map +1 -1
- package/dist/core/docker.js.map +1 -1
- package/dist/core/envs.cjs +34 -0
- package/dist/core/envs.cjs.map +1 -1
- package/dist/core/envs.d.ts +8 -2
- package/dist/core/envs.d.ts.map +1 -1
- package/dist/core/envs.js +13 -1
- package/dist/core/envs.js.map +1 -1
- package/dist/core/package-info.cjs +59 -5
- package/dist/core/package-info.cjs.map +1 -1
- package/dist/core/package-info.d.ts +11 -2
- package/dist/core/package-info.d.ts.map +1 -1
- package/dist/core/package-info.js +60 -6
- package/dist/core/package-info.js.map +1 -1
- package/dist/core/paths.cjs +1 -1
- package/dist/core/paths.cjs.map +1 -1
- package/dist/core/paths.js +1 -1
- package/dist/core/paths.js.map +1 -1
- package/dist/core/resolver.cjs +7 -2
- package/dist/core/resolver.cjs.map +1 -1
- package/dist/core/resolver.js +1 -1
- package/dist/core/resolver.js.map +1 -1
- package/dist/core/schemas/artifacts.cjs +7 -1
- package/dist/core/schemas/artifacts.cjs.map +1 -1
- package/dist/core/schemas/artifacts.d.ts +1 -1
- package/dist/core/schemas/artifacts.d.ts.map +1 -1
- package/dist/core/schemas/artifacts.js +1 -1
- package/dist/core/schemas/artifacts.js.map +1 -1
- package/dist/core/schemas/entrypoints.cjs +4 -1
- package/dist/core/schemas/entrypoints.cjs.map +1 -1
- package/dist/core/schemas/entrypoints.d.ts +1 -1
- package/dist/core/schemas/entrypoints.d.ts.map +1 -1
- package/dist/core/schemas/entrypoints.js +1 -1
- package/dist/core/schemas/entrypoints.js.map +1 -1
- package/dist/core/schemas/sw-json.cjs +16 -1
- package/dist/core/schemas/sw-json.cjs.map +1 -1
- package/dist/core/schemas/sw-json.js +1 -1
- package/dist/core/schemas/sw-json.js.map +1 -1
- package/dist/core/storage.cjs +6 -2
- package/dist/core/storage.cjs.map +1 -1
- package/dist/core/storage.js +4 -1
- package/dist/core/storage.js.map +1 -1
- package/dist/core/sw-json-render.cjs +38 -7
- package/dist/core/sw-json-render.cjs.map +1 -1
- package/dist/core/sw-json-render.js +37 -8
- package/dist/core/sw-json-render.js.map +1 -1
- package/dist/core/util.cjs +33 -12
- package/dist/core/util.cjs.map +1 -1
- package/dist/core/util.d.ts +12 -7
- package/dist/core/util.d.ts.map +1 -1
- package/dist/core/util.js +17 -8
- package/dist/core/util.js.map +1 -1
- package/dist/defaults.cjs +18 -1
- package/dist/defaults.cjs.map +1 -1
- package/dist/defaults.d.ts +9 -3
- package/dist/defaults.d.ts.map +1 -1
- package/dist/defaults.js +13 -2
- package/dist/defaults.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/core/core.test.ts +17 -0
- package/src/core/core.ts +48 -8
- package/src/core/envs.ts +8 -0
- package/src/core/package-info.test.ts +162 -3
- package/src/core/package-info.ts +88 -3
- package/src/core/schemas/test-artifacts.ts +1 -1
- package/src/core/sw-json-render.test.ts +23 -0
- package/src/core/sw-json-render.ts +30 -2
- package/src/core/util.test.ts +52 -0
- package/src/core/util.ts +27 -7
- package/src/defaults.ts +19 -1
- package/src/index.ts +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoints.cjs","names":["z"],"sources":["../../../src/core/schemas/entrypoints.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport * as artifacts from \"./artifacts\";\nimport * as util from \"../util\";\n\nconst envVarsSchema = z.array(\n z\n .string()\n .regex(\n /=/,\n \"full environment variable specification is required: <var-name>=<var-value>, e.g.: IS_CI=yes\",\n ),\n);\n\nexport const EnyrypointReferencePattern =\n /^(?<fullName>(?:(?<scope>@[a-z0-9-.]+)\\/)?(?<name>[a-z0-9-.]+))\\/(?<path>.*)$/;\n\nexport const referenceSchema = z\n .string()\n .regex(\n EnyrypointReferencePattern,\n \"entrypoint reference must contain full package name and path to the file inside\",\n );\n\nconst orRef = <T extends z.ZodTypeAny>(schema: T) =>\n z.union([\n z\n .string(\"not a reference to artifact\")\n .describe('reference to artifact in \"artifacts\" section'),\n schema,\n ]);\n\n// Common options for all software packages: everything that can be run on backend side.\nexport const softwareOptionsSchema = z.strictObject({\n cmd: z\n .array(z.string(\"command artument must be a string\"))\n .min(1, { error: \"at least one argument is required\" })\n .refine((cmd) => cmd[0].trim() != \"\", { error: \"first cmd argument must be non-empty string\" })\n .describe(\n \"command to run for this entrypoint. This command will be appended by <args> set inside workflow\",\n ),\n envVars: envVarsSchema\n .optional()\n .describe(\"list of environment variables to be set for this entrypoint\"),\n});\nexport type softwareOptionsType = z.infer<typeof softwareOptionsSchema>;\n\nexport const environmentOptionsSchema = z.strictObject({\n artifact: orRef(artifacts.environmentSchema.omit({ type: true })),\n envVars: envVarsSchema\n .optional()\n .describe(\n \"list of environment variables to be set for any command inside this run environment\",\n ),\n});\n\n// Full schema of single entrypoint in block-software.entrypoints\nexport const entrypointSchema = z\n .strictObject({\n reference: referenceSchema.optional(),\n asset: orRef(artifacts.assetSchema.omit({ type: true })).optional(),\n environment: environmentOptionsSchema.optional(),\n\n binary: z\n .union([\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.binarySchema) }),\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.javaSchema) }),\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.pythonSchema) }),\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.rSchema) }),\n ])\n .optional(), // TODO: reduce nesting: put java, python and r to the level of binary, like conda.\n\n conda: softwareOptionsSchema\n .extend({ artifact: orRef(artifacts.condaSchema.omit({ type: true })) })\n .optional(),\n docker: softwareOptionsSchema\n .extend({ artifact: orRef(artifacts.dockerSchema.omit({ type: true })) })\n .optional(),\n })\n .refine(\n (data) => {\n const n =\n util.toInt(data.reference) +\n util.toInt(data.asset && !data.docker) + // no docker for assets\n util.toInt(data.binary || (data.binary && data.docker)) + // allow both docker and binary to be set in single entrypoint\n util.toInt(data.conda || (data.conda && data.docker)) + // allow both docker and conda to be set in single entrypoint\n util.toInt(data.environment && !data.docker); // no docker for environments\n\n if (n === 0) {\n return Boolean(data.docker); // allow separate docker entrypoints (without binary/conda/...)\n }\n\n return n === 1;\n },\n {\n message:\n \"entrypoint cannot point to several packages at once: choose 'reference', 'asset', 'binary', 'environment' or 'docker'\",\n path: [\"reference | asset | binary | environment | docker\"],\n },\n );\nexport type entrypointType = z.infer<typeof entrypointSchema>;\n\n// Full block-software.entrypoints list schema\nexport const entrypointListSchema = z.record(\n z\n .string()\n .regex(/[-_a-z0-9.]/)\n .describe(\n \"name of entrypoint descriptor, client should import to use this entrypoint (assets.importSoftware)\",\n ),\n entrypointSchema,\n);\nexport type entrypointListType = z.infer<typeof entrypointListSchema>;\n\nexport interface ReferenceEntrypoint {\n type: \"reference\";\n name: string;\n reference: string;\n}\n\nexport interface AssetEntrypoint {\n type: \"asset\";\n name: string;\n artifact: artifacts.withId<artifacts.assetType>;\n}\n\nexport interface SoftwareEntrypoint {\n type: \"software\";\n name: string;\n artifact: artifacts.withId<\n | artifacts.binaryType\n | artifacts.condaType\n | artifacts.javaType\n | artifacts.pythonType\n | artifacts.rType\n | artifacts.dockerType\n >;\n cmd: string[];\n env: string[];\n}\n\nexport interface EnvironmentEntrypoint {\n type: \"environment\";\n name: string;\n artifact: artifacts.withId<artifacts.environmentType>;\n env: string[];\n}\n\nexport type PackageEntrypoint = AssetEntrypoint | SoftwareEntrypoint | EnvironmentEntrypoint;\nexport type Entrypoint = ReferenceEntrypoint | PackageEntrypoint;\nexport type EntrypointType = Extract<Entrypoint, { type: string }>[\"type\"];\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"entrypoints.cjs","names":["z"],"sources":["../../../src/core/schemas/entrypoints.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport * as artifacts from \"./artifacts\";\nimport * as util from \"../util\";\n\nconst envVarsSchema = z.array(\n z\n .string()\n .regex(\n /=/,\n \"full environment variable specification is required: <var-name>=<var-value>, e.g.: IS_CI=yes\",\n ),\n);\n\nexport const EnyrypointReferencePattern =\n /^(?<fullName>(?:(?<scope>@[a-z0-9-.]+)\\/)?(?<name>[a-z0-9-.]+))\\/(?<path>.*)$/;\n\nexport const referenceSchema = z\n .string()\n .regex(\n EnyrypointReferencePattern,\n \"entrypoint reference must contain full package name and path to the file inside\",\n );\n\nconst orRef = <T extends z.ZodTypeAny>(schema: T) =>\n z.union([\n z\n .string(\"not a reference to artifact\")\n .describe('reference to artifact in \"artifacts\" section'),\n schema,\n ]);\n\n// Common options for all software packages: everything that can be run on backend side.\nexport const softwareOptionsSchema = z.strictObject({\n cmd: z\n .array(z.string(\"command artument must be a string\"))\n .min(1, { error: \"at least one argument is required\" })\n .refine((cmd) => cmd[0].trim() != \"\", { error: \"first cmd argument must be non-empty string\" })\n .describe(\n \"command to run for this entrypoint. This command will be appended by <args> set inside workflow\",\n ),\n envVars: envVarsSchema\n .optional()\n .describe(\"list of environment variables to be set for this entrypoint\"),\n});\nexport type softwareOptionsType = z.infer<typeof softwareOptionsSchema>;\n\nexport const environmentOptionsSchema = z.strictObject({\n artifact: orRef(artifacts.environmentSchema.omit({ type: true })),\n envVars: envVarsSchema\n .optional()\n .describe(\n \"list of environment variables to be set for any command inside this run environment\",\n ),\n});\n\n// Full schema of single entrypoint in block-software.entrypoints\nexport const entrypointSchema = z\n .strictObject({\n reference: referenceSchema.optional(),\n asset: orRef(artifacts.assetSchema.omit({ type: true })).optional(),\n environment: environmentOptionsSchema.optional(),\n\n binary: z\n .union([\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.binarySchema) }),\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.javaSchema) }),\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.pythonSchema) }),\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.rSchema) }),\n ])\n .optional(), // TODO: reduce nesting: put java, python and r to the level of binary, like conda.\n\n conda: softwareOptionsSchema\n .extend({ artifact: orRef(artifacts.condaSchema.omit({ type: true })) })\n .optional(),\n docker: softwareOptionsSchema\n .extend({ artifact: orRef(artifacts.dockerSchema.omit({ type: true })) })\n .optional(),\n })\n .refine(\n (data) => {\n const n =\n util.toInt(data.reference) +\n util.toInt(data.asset && !data.docker) + // no docker for assets\n util.toInt(data.binary || (data.binary && data.docker)) + // allow both docker and binary to be set in single entrypoint\n util.toInt(data.conda || (data.conda && data.docker)) + // allow both docker and conda to be set in single entrypoint\n util.toInt(data.environment && !data.docker); // no docker for environments\n\n if (n === 0) {\n return Boolean(data.docker); // allow separate docker entrypoints (without binary/conda/...)\n }\n\n return n === 1;\n },\n {\n message:\n \"entrypoint cannot point to several packages at once: choose 'reference', 'asset', 'binary', 'environment' or 'docker'\",\n path: [\"reference | asset | binary | environment | docker\"],\n },\n );\nexport type entrypointType = z.infer<typeof entrypointSchema>;\n\n// Full block-software.entrypoints list schema\nexport const entrypointListSchema = z.record(\n z\n .string()\n .regex(/[-_a-z0-9.]/)\n .describe(\n \"name of entrypoint descriptor, client should import to use this entrypoint (assets.importSoftware)\",\n ),\n entrypointSchema,\n);\nexport type entrypointListType = z.infer<typeof entrypointListSchema>;\n\nexport interface ReferenceEntrypoint {\n type: \"reference\";\n name: string;\n reference: string;\n}\n\nexport interface AssetEntrypoint {\n type: \"asset\";\n name: string;\n artifact: artifacts.withId<artifacts.assetType>;\n}\n\nexport interface SoftwareEntrypoint {\n type: \"software\";\n name: string;\n artifact: artifacts.withId<\n | artifacts.binaryType\n | artifacts.condaType\n | artifacts.javaType\n | artifacts.pythonType\n | artifacts.rType\n | artifacts.dockerType\n >;\n cmd: string[];\n env: string[];\n}\n\nexport interface EnvironmentEntrypoint {\n type: \"environment\";\n name: string;\n artifact: artifacts.withId<artifacts.environmentType>;\n env: string[];\n}\n\nexport type PackageEntrypoint = AssetEntrypoint | SoftwareEntrypoint | EnvironmentEntrypoint;\nexport type Entrypoint = ReferenceEntrypoint | PackageEntrypoint;\nexport type EntrypointType = Extract<Entrypoint, { type: string }>[\"type\"];\n"],"mappings":";;;;AAIA,MAAM,gBAAgBA,OAAAA,EAAE,MACtBA,OAAAA,EACG,OAAO,CAAC,CACR,MACC,KACA,8FACF,CACJ;AAEA,MAAa,6BACX;AAEF,MAAa,kBAAkBA,OAAAA,EAC5B,OAAO,CAAC,CACR,MACC,4BACA,iFACF;AAEF,MAAM,SAAiC,WACrCA,OAAAA,EAAE,MAAM,CACNA,OAAAA,EACG,OAAO,6BAA6B,CAAC,CACrC,SAAS,gDAA8C,GAC1D,MACF,CAAC;AAGH,MAAa,wBAAwBA,OAAAA,EAAE,aAAa;CAClD,KAAKA,OAAAA,EACF,MAAMA,OAAAA,EAAE,OAAO,mCAAmC,CAAC,CAAC,CACpD,IAAI,GAAG,EAAE,OAAO,oCAAoC,CAAC,CAAC,CACtD,QAAQ,QAAQ,IA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AAO,IAAA,aAAA,MAC3C,KAAK,SAAU,KAAK,SAAS,KAAK,MAAO,IAAA,aAAA,MACzC,KAAK,eAAe,CAAC,KAAK,MAAM;CAE7C,IAAI,MAAM,GACR,OAAO,QAAQ,KAAK,MAAM;CAG5B,OAAO,MAAM;AACf,GACA;CACE,SACE;CACF,MAAM,CAAC,mDAAmD;AAC5D,CACF;AAIF,MAAa,uBAAuBA,OAAAA,EAAE,OACpCA,OAAAA,EACG,OAAO,CAAC,CACR,MAAM,aAAa,CAAC,CACpB,SACC,oGACF,GACF,gBACF"}
|
|
@@ -28,5 +28,5 @@ interface EnvironmentEntrypoint {
|
|
|
28
28
|
type PackageEntrypoint = AssetEntrypoint | SoftwareEntrypoint | EnvironmentEntrypoint;
|
|
29
29
|
type Entrypoint = ReferenceEntrypoint | PackageEntrypoint;
|
|
30
30
|
//#endregion
|
|
31
|
-
export { Entrypoint, ReferenceEntrypoint };
|
|
31
|
+
export { AssetEntrypoint, Entrypoint, EnvironmentEntrypoint, PackageEntrypoint, ReferenceEntrypoint, SoftwareEntrypoint };
|
|
32
32
|
//# sourceMappingURL=entrypoints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoints.d.ts","names":[],"sources":["../../../src/core/schemas/entrypoints.ts"],"mappings":";;;;UAiHiB,mBAAA;EACf,IAAA;EACA,IAAA;EACA,SAAA;AAAA;AAAA,UAGe,eAAA;EACf,IAAA;EACA,IAAA;EACA,QAAA,EAAU,
|
|
1
|
+
{"version":3,"file":"entrypoints.d.ts","names":[],"sources":["../../../src/core/schemas/entrypoints.ts"],"mappings":";;;;UAiHiB,mBAAA;EACf,IAAA;EACA,IAAA;EACA,SAAA;AAAA;AAAA,UAGe,eAAA;EACf,IAAA;EACA,IAAA;EACA,QAAA,EAAU,MAAgB,CAAC,SAAA;AAAA;AAAA,UAGZ,kBAAA;EACf,IAAA;EACA,IAAA;EACA,QAAA,EAAU,MAAA,CACN,UAAA,GACA,SAAA,GACA,QAAA,GACA,UAAA,GACA,KAAA,GACA,UAAA;EAEJ,GAAA;EACA,GAAA;AAAA;AAAA,UAGe,qBAAA;EACf,IAAA;EACA,IAAA;EACA,QAAA,EAAU,MAAgB,CAAC,eAAA;EAC3B,GAAA;AAAA;AAAA,KAGU,iBAAA,GAAoB,eAAA,GAAkB,kBAAA,GAAqB,qBAAA;AAAA,KAC3D,UAAA,GAAa,mBAAA,GAAsB,iBAAiB"}
|
|
@@ -36,6 +36,6 @@ const entrypointSchema = z.strictObject({
|
|
|
36
36
|
});
|
|
37
37
|
const entrypointListSchema = z.record(z.string().regex(/[-_a-z0-9.]/).describe("name of entrypoint descriptor, client should import to use this entrypoint (assets.importSoftware)"), entrypointSchema);
|
|
38
38
|
//#endregion
|
|
39
|
-
export { EnyrypointReferencePattern, entrypointListSchema };
|
|
39
|
+
export { EnyrypointReferencePattern, entrypointListSchema, entrypointSchema, environmentOptionsSchema, referenceSchema, softwareOptionsSchema };
|
|
40
40
|
|
|
41
41
|
//# sourceMappingURL=entrypoints.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoints.js","names":["artifacts.binarySchema","artifacts.javaSchema","artifacts.pythonSchema","artifacts.rSchema","util.toInt"],"sources":["../../../src/core/schemas/entrypoints.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport * as artifacts from \"./artifacts\";\nimport * as util from \"../util\";\n\nconst envVarsSchema = z.array(\n z\n .string()\n .regex(\n /=/,\n \"full environment variable specification is required: <var-name>=<var-value>, e.g.: IS_CI=yes\",\n ),\n);\n\nexport const EnyrypointReferencePattern =\n /^(?<fullName>(?:(?<scope>@[a-z0-9-.]+)\\/)?(?<name>[a-z0-9-.]+))\\/(?<path>.*)$/;\n\nexport const referenceSchema = z\n .string()\n .regex(\n EnyrypointReferencePattern,\n \"entrypoint reference must contain full package name and path to the file inside\",\n );\n\nconst orRef = <T extends z.ZodTypeAny>(schema: T) =>\n z.union([\n z\n .string(\"not a reference to artifact\")\n .describe('reference to artifact in \"artifacts\" section'),\n schema,\n ]);\n\n// Common options for all software packages: everything that can be run on backend side.\nexport const softwareOptionsSchema = z.strictObject({\n cmd: z\n .array(z.string(\"command artument must be a string\"))\n .min(1, { error: \"at least one argument is required\" })\n .refine((cmd) => cmd[0].trim() != \"\", { error: \"first cmd argument must be non-empty string\" })\n .describe(\n \"command to run for this entrypoint. This command will be appended by <args> set inside workflow\",\n ),\n envVars: envVarsSchema\n .optional()\n .describe(\"list of environment variables to be set for this entrypoint\"),\n});\nexport type softwareOptionsType = z.infer<typeof softwareOptionsSchema>;\n\nexport const environmentOptionsSchema = z.strictObject({\n artifact: orRef(artifacts.environmentSchema.omit({ type: true })),\n envVars: envVarsSchema\n .optional()\n .describe(\n \"list of environment variables to be set for any command inside this run environment\",\n ),\n});\n\n// Full schema of single entrypoint in block-software.entrypoints\nexport const entrypointSchema = z\n .strictObject({\n reference: referenceSchema.optional(),\n asset: orRef(artifacts.assetSchema.omit({ type: true })).optional(),\n environment: environmentOptionsSchema.optional(),\n\n binary: z\n .union([\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.binarySchema) }),\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.javaSchema) }),\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.pythonSchema) }),\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.rSchema) }),\n ])\n .optional(), // TODO: reduce nesting: put java, python and r to the level of binary, like conda.\n\n conda: softwareOptionsSchema\n .extend({ artifact: orRef(artifacts.condaSchema.omit({ type: true })) })\n .optional(),\n docker: softwareOptionsSchema\n .extend({ artifact: orRef(artifacts.dockerSchema.omit({ type: true })) })\n .optional(),\n })\n .refine(\n (data) => {\n const n =\n util.toInt(data.reference) +\n util.toInt(data.asset && !data.docker) + // no docker for assets\n util.toInt(data.binary || (data.binary && data.docker)) + // allow both docker and binary to be set in single entrypoint\n util.toInt(data.conda || (data.conda && data.docker)) + // allow both docker and conda to be set in single entrypoint\n util.toInt(data.environment && !data.docker); // no docker for environments\n\n if (n === 0) {\n return Boolean(data.docker); // allow separate docker entrypoints (without binary/conda/...)\n }\n\n return n === 1;\n },\n {\n message:\n \"entrypoint cannot point to several packages at once: choose 'reference', 'asset', 'binary', 'environment' or 'docker'\",\n path: [\"reference | asset | binary | environment | docker\"],\n },\n );\nexport type entrypointType = z.infer<typeof entrypointSchema>;\n\n// Full block-software.entrypoints list schema\nexport const entrypointListSchema = z.record(\n z\n .string()\n .regex(/[-_a-z0-9.]/)\n .describe(\n \"name of entrypoint descriptor, client should import to use this entrypoint (assets.importSoftware)\",\n ),\n entrypointSchema,\n);\nexport type entrypointListType = z.infer<typeof entrypointListSchema>;\n\nexport interface ReferenceEntrypoint {\n type: \"reference\";\n name: string;\n reference: string;\n}\n\nexport interface AssetEntrypoint {\n type: \"asset\";\n name: string;\n artifact: artifacts.withId<artifacts.assetType>;\n}\n\nexport interface SoftwareEntrypoint {\n type: \"software\";\n name: string;\n artifact: artifacts.withId<\n | artifacts.binaryType\n | artifacts.condaType\n | artifacts.javaType\n | artifacts.pythonType\n | artifacts.rType\n | artifacts.dockerType\n >;\n cmd: string[];\n env: string[];\n}\n\nexport interface EnvironmentEntrypoint {\n type: \"environment\";\n name: string;\n artifact: artifacts.withId<artifacts.environmentType>;\n env: string[];\n}\n\nexport type PackageEntrypoint = AssetEntrypoint | SoftwareEntrypoint | EnvironmentEntrypoint;\nexport type Entrypoint = ReferenceEntrypoint | PackageEntrypoint;\nexport type EntrypointType = Extract<Entrypoint, { type: string }>[\"type\"];\n"],"mappings":";;;;AAIA,MAAM,gBAAgB,EAAE,MACtB,EACG,
|
|
1
|
+
{"version":3,"file":"entrypoints.js","names":["artifacts.binarySchema","artifacts.javaSchema","artifacts.pythonSchema","artifacts.rSchema","util.toInt"],"sources":["../../../src/core/schemas/entrypoints.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport * as artifacts from \"./artifacts\";\nimport * as util from \"../util\";\n\nconst envVarsSchema = z.array(\n z\n .string()\n .regex(\n /=/,\n \"full environment variable specification is required: <var-name>=<var-value>, e.g.: IS_CI=yes\",\n ),\n);\n\nexport const EnyrypointReferencePattern =\n /^(?<fullName>(?:(?<scope>@[a-z0-9-.]+)\\/)?(?<name>[a-z0-9-.]+))\\/(?<path>.*)$/;\n\nexport const referenceSchema = z\n .string()\n .regex(\n EnyrypointReferencePattern,\n \"entrypoint reference must contain full package name and path to the file inside\",\n );\n\nconst orRef = <T extends z.ZodTypeAny>(schema: T) =>\n z.union([\n z\n .string(\"not a reference to artifact\")\n .describe('reference to artifact in \"artifacts\" section'),\n schema,\n ]);\n\n// Common options for all software packages: everything that can be run on backend side.\nexport const softwareOptionsSchema = z.strictObject({\n cmd: z\n .array(z.string(\"command artument must be a string\"))\n .min(1, { error: \"at least one argument is required\" })\n .refine((cmd) => cmd[0].trim() != \"\", { error: \"first cmd argument must be non-empty string\" })\n .describe(\n \"command to run for this entrypoint. This command will be appended by <args> set inside workflow\",\n ),\n envVars: envVarsSchema\n .optional()\n .describe(\"list of environment variables to be set for this entrypoint\"),\n});\nexport type softwareOptionsType = z.infer<typeof softwareOptionsSchema>;\n\nexport const environmentOptionsSchema = z.strictObject({\n artifact: orRef(artifacts.environmentSchema.omit({ type: true })),\n envVars: envVarsSchema\n .optional()\n .describe(\n \"list of environment variables to be set for any command inside this run environment\",\n ),\n});\n\n// Full schema of single entrypoint in block-software.entrypoints\nexport const entrypointSchema = z\n .strictObject({\n reference: referenceSchema.optional(),\n asset: orRef(artifacts.assetSchema.omit({ type: true })).optional(),\n environment: environmentOptionsSchema.optional(),\n\n binary: z\n .union([\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.binarySchema) }),\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.javaSchema) }),\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.pythonSchema) }),\n softwareOptionsSchema.extend({ artifact: orRef(artifacts.rSchema) }),\n ])\n .optional(), // TODO: reduce nesting: put java, python and r to the level of binary, like conda.\n\n conda: softwareOptionsSchema\n .extend({ artifact: orRef(artifacts.condaSchema.omit({ type: true })) })\n .optional(),\n docker: softwareOptionsSchema\n .extend({ artifact: orRef(artifacts.dockerSchema.omit({ type: true })) })\n .optional(),\n })\n .refine(\n (data) => {\n const n =\n util.toInt(data.reference) +\n util.toInt(data.asset && !data.docker) + // no docker for assets\n util.toInt(data.binary || (data.binary && data.docker)) + // allow both docker and binary to be set in single entrypoint\n util.toInt(data.conda || (data.conda && data.docker)) + // allow both docker and conda to be set in single entrypoint\n util.toInt(data.environment && !data.docker); // no docker for environments\n\n if (n === 0) {\n return Boolean(data.docker); // allow separate docker entrypoints (without binary/conda/...)\n }\n\n return n === 1;\n },\n {\n message:\n \"entrypoint cannot point to several packages at once: choose 'reference', 'asset', 'binary', 'environment' or 'docker'\",\n path: [\"reference | asset | binary | environment | docker\"],\n },\n );\nexport type entrypointType = z.infer<typeof entrypointSchema>;\n\n// Full block-software.entrypoints list schema\nexport const entrypointListSchema = z.record(\n z\n .string()\n .regex(/[-_a-z0-9.]/)\n .describe(\n \"name of entrypoint descriptor, client should import to use this entrypoint (assets.importSoftware)\",\n ),\n entrypointSchema,\n);\nexport type entrypointListType = z.infer<typeof entrypointListSchema>;\n\nexport interface ReferenceEntrypoint {\n type: \"reference\";\n name: string;\n reference: string;\n}\n\nexport interface AssetEntrypoint {\n type: \"asset\";\n name: string;\n artifact: artifacts.withId<artifacts.assetType>;\n}\n\nexport interface SoftwareEntrypoint {\n type: \"software\";\n name: string;\n artifact: artifacts.withId<\n | artifacts.binaryType\n | artifacts.condaType\n | artifacts.javaType\n | artifacts.pythonType\n | artifacts.rType\n | artifacts.dockerType\n >;\n cmd: string[];\n env: string[];\n}\n\nexport interface EnvironmentEntrypoint {\n type: \"environment\";\n name: string;\n artifact: artifacts.withId<artifacts.environmentType>;\n env: string[];\n}\n\nexport type PackageEntrypoint = AssetEntrypoint | SoftwareEntrypoint | EnvironmentEntrypoint;\nexport type Entrypoint = ReferenceEntrypoint | Pack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ACD,SAAS;CAEZ,OAAO,sBACJ,OAAO,EAAE,UAAU,MAAA,YAA4B,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CACvE,SAAS;CACZ,QAAQ,sBACL,OAAO,EAAE,UAAU,MAAA,aAA6B,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CACxE,SAAS;AACd,CAAC,CAAC,CACD,QACE,SAAS;CACR,MAAM,IACJC,MAAW,KAAK,SAAS,IACzBA,MAAW,KAAK,SAAS,CAAC,KAAK,MAAM,IACrCA,MAAW,KAAK,UAAW,KAAK,UAAU,KAAK,MAAO,IACtDA,MAAW,KAAK,SAAU,KAAK,SAAS,KAAK,MAAO,IACpDA,MAAW,KAAK,eAAe,CAAC,KAAK,MAAM;CAE7C,IAAI,MAAM,GACR,OAAO,QAAQ,KAAK,MAAM;CAG5B,OAAO,MAAM;AACf,GACA;CACE,SACE;CACF,MAAM,CAAC,mDAAmD;AAC5D,CACF;AAIF,MAAa,uBAAuB,EAAE,OACpC,EACG,OAAO,CAAC,CACR,MAAM,aAAa,CAAC,CACpB,SACC,oGACF,GACF,gBACF"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
1
|
const require_defaults = require("../../defaults.cjs");
|
|
3
2
|
const require_util = require("../util.cjs");
|
|
4
3
|
const require_artifacts = require("./artifacts.cjs");
|
|
@@ -106,6 +105,22 @@ const swJsonSchema = zod_v4.z.object({
|
|
|
106
105
|
path: ["environment | binary | asset | conda | local"]
|
|
107
106
|
});
|
|
108
107
|
//#endregion
|
|
108
|
+
exports.assetSchema = assetSchema;
|
|
109
|
+
exports.binaryPackageSchema = binaryPackageSchema;
|
|
110
|
+
exports.commonPackageSettingsSchema = commonPackageSettingsSchema;
|
|
111
|
+
exports.condaPackageSchema = condaPackageSchema;
|
|
112
|
+
exports.dockerSchema = dockerSchema;
|
|
113
|
+
exports.javaPackageSettingsSchema = javaPackageSettingsSchema;
|
|
114
|
+
exports.localLocationSchema = localLocationSchema;
|
|
115
|
+
exports.localSoftwareSchema = localSoftwareSchema;
|
|
116
|
+
exports.pythonPackageSettingsSchema = pythonPackageSettingsSchema;
|
|
117
|
+
exports.rPackageSettingsSchema = rPackageSettingsSchema;
|
|
118
|
+
exports.remoteLocationSchema = remoteLocationSchema;
|
|
119
|
+
exports.remoteSoftwareSchema = remoteSoftwareSchema;
|
|
120
|
+
exports.runDependencyJavaSchema = runDependencyJavaSchema;
|
|
121
|
+
exports.runDependencyPythonSchema = runDependencyPythonSchema;
|
|
122
|
+
exports.runDependencyRSchema = runDependencyRSchema;
|
|
123
|
+
exports.runEnvironmentSchema = runEnvironmentSchema;
|
|
109
124
|
exports.swJsonSchema = swJsonSchema;
|
|
110
125
|
|
|
111
126
|
//# sourceMappingURL=sw-json.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sw-json.cjs","names":["z"],"sources":["../../../src/core/schemas/sw-json.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport * as defaults from \"../../defaults\";\nimport * as artifacts from \"./artifacts\";\nimport * as util from \"../util\";\n\nexport const remoteLocationSchema = z.object({\n registry: z.string().describe(\"name of the registry to use for package download\"),\n package: z\n .string()\n .describe(\"full package path in registry, e.g. 'common/jdk/21.0.2.13.1-{os}-{arch}.tgz\"),\n});\n\nexport const assetSchema = z.object({\n ...remoteLocationSchema.shape,\n url: z.string().describe(\"asset download URL\"),\n});\nexport type assetInfo = z.infer<typeof assetSchema>;\n\nexport const dockerSchema = z.object({\n tag: z.string().describe(\"full image tag to pull on backend side to execute this software\"),\n entrypoint: z.array(z.string()).describe(\"override image's entrypoint\"),\n cmd: z.array(z.string()).describe(\"command to be run in the container\"),\n\n pkg: z\n .string()\n .default(defaults.DOCKER_PLACEHOLDER_PKG)\n .describe(\n 'what to substitute in place of \"{pkg}\" variable in \"cmd\" (for artifacts with docker autogeneration)',\n ),\n});\nexport type dockerInfo = z.infer<typeof dockerSchema>;\n\nexport const runEnvironmentSchema = z.object({\n type: z.enum(artifacts.runEnvironmentTypes),\n ...remoteLocationSchema.shape,\n\n [\"r-version\"]: z.string().optional(),\n [\"python-version\"]: z.string().optional(),\n [\"java-version\"]: z.string().optional(),\n\n envVars: z\n .array(\n z\n .string()\n .regex(\n /=/,\n \"environment variable should be specified in format: <var-name>=<var-value>, i.e.: MY_ENV=value\",\n ),\n )\n .optional(),\n\n binDir: z.string(),\n});\nexport type runEnvInfo = z.infer<typeof runEnvironmentSchema>;\n\nexport const runDependencyJavaSchema = runEnvironmentSchema.extend({\n type: z.literal(\"java\"),\n name: z\n .string()\n .describe(\"name used to import this package as software dependency of tengo script\"),\n});\nexport type runEnvDependencyJava = z.infer<typeof runDependencyJavaSchema>;\n\nexport const runDependencyPythonSchema = runEnvironmentSchema.extend({\n type: z.literal(\"python\"),\n [\"python-version\"]: z.string(),\n name: z\n .string()\n .describe(\"name used to import this package as software dependency of tengo script\"),\n});\nexport type runEnvDependencyPython = z.infer<typeof runDependencyPythonSchema>;\n\nexport const runDependencyRSchema = runEnvironmentSchema.extend({\n type: z.literal(\"R\"),\n [\"r-version\"]: z.string(),\n name: z\n .string()\n .describe(\"name used to import this package as software dependency of tengo script\"),\n});\nexport type runEnvDependencyR = z.infer<typeof runDependencyRSchema>;\n\nexport type runEnvDependency = runEnvDependencyJava | runEnvDependencyPython | runEnvDependencyR;\n\nexport const commonPackageSettingsSchema = z.object({\n cmd: z.array(z.string()).min(1).describe(\"run given command, appended by args from workflow\"),\n\n envVars: z\n .array(\n z\n .string()\n .regex(\n /=/,\n \"full environment variable specification is required: <var-name>=<var-value>, e.g.: IS_CI=yes\",\n ),\n )\n .optional(),\n});\n\nexport const binaryPackageSchema = z.object({\n type: z.literal(\"binary\"),\n ...commonPackageSettingsSchema.shape,\n\n pkg: z\n .string()\n .optional()\n .describe(\"location of all package contents in Docker container (default: /app)\"),\n});\n\nexport const javaPackageSettingsSchema = z.object({\n type: z.literal(\"java\"),\n\n ...commonPackageSettingsSchema.shape,\n runEnv: runDependencyJavaSchema,\n});\n\nexport const pythonPackageSettingsSchema = z.object({\n type: z.literal(\"python\"),\n\n ...commonPackageSettingsSchema.shape,\n runEnv: runDependencyPythonSchema,\n\n toolset: z.string(),\n dependencies: z\n .record(z.string(), z.string())\n .describe(\n \"paths of files that describe dependencies for given toolset: say, requirements.txt for 'pip'\",\n ),\n});\n\nexport const rPackageSettingsSchema = z.object({\n type: z.literal(\"R\"),\n\n ...commonPackageSettingsSchema.shape,\n runEnv: runDependencyRSchema,\n\n toolset: z.string(),\n dependencies: z\n .record(z.string(), z.string())\n .describe(\n \"paths of files that describe dependencies for given toolset: say, requirements.txt for 'pip'\",\n ),\n});\n\nexport const condaPackageSchema = z.object({\n type: z.literal(\"conda\"),\n ...commonPackageSettingsSchema.shape,\n\n [\"micromamba-version\"]: z\n .string()\n .describe(\"version of micromamba to be used to operate with conda environments\"),\n [\"conda-root-dir\"]: z\n .string()\n .default(defaults.CONDA_DATA_LOCATION)\n .describe(\"root directory of conda environment inside package root\"),\n\n spec: z\n .string()\n .describe(\"location of spec.yaml describing conda environment, relative to package root.\"),\n});\n\nexport const remoteSoftwareSchema = z.union([\n remoteLocationSchema.extend(binaryPackageSchema.shape),\n remoteLocationSchema.extend(javaPackageSettingsSchema.shape),\n remoteLocationSchema.extend(pythonPackageSettingsSchema.shape),\n remoteLocationSchema.extend(rPackageSettingsSchema.shape),\n remoteLocationSchema.extend(condaPackageSchema.shape),\n]);\nexport type remoteSoftwareType = z.infer<typeof remoteSoftwareSchema>;\n\nexport const localLocationSchema = z.object({\n hash: z\n .string()\n .describe(\n \"hash of software directory. Makes deduplication to work properly when you actively develop software\",\n ),\n path: z.string().describe(\"absolute path to root directory of software on local host\"),\n});\n\nexport const localSoftwareSchema = z.discriminatedUnion(\"type\", [\n localLocationSchema.extend(binaryPackageSchema.shape),\n localLocationSchema.extend(javaPackageSettingsSchema.shape),\n localLocationSchema.extend(pythonPackageSettingsSchema.shape),\n localLocationSchema.extend(rPackageSettingsSchema.shape),\n localLocationSchema.extend(condaPackageSchema.shape),\n // Docker can be used 'as usual' without any special 'local' section magic\n]);\nexport type localSoftwareType = z.infer<typeof localSoftwareSchema>;\n\n// Full .sw.json file schema\nexport const swJsonSchema = z\n .object({\n isDev: z.boolean().optional(),\n\n asset: assetSchema.optional(),\n binary: remoteSoftwareSchema.optional(),\n docker: dockerSchema.optional(),\n runEnv: runEnvironmentSchema.optional(),\n local: localSoftwareSchema.optional(),\n })\n .refine(\n (data) =>\n util.toInt(data.runEnv) +\n util.toInt(data.binary || data.docker) + // allow both docker and binary to be set in single entrypoint\n util.toInt(data.asset) +\n util.toInt(data.local) ==\n 1,\n {\n message:\n \"entrypoint cannot point to several packages at once: choose 'environment', 'binary', 'asset', 'conda' or 'local'\",\n path: [\"environment | binary | asset | conda | local\"],\n },\n );\n\nexport type swJsonType = z.infer<typeof swJsonSchema> & {\n id: util.artifactID;\n};\n"],"mappings":";;;;;;AAKA,MAAa,uBAAuBA,OAAAA,EAAE,OAAO;CAC3C,UAAUA,OAAAA,EAAE,QAAQ,CAAC,SAAS,mDAAmD;CACjF,SAASA,OAAAA,EACN,QAAQ,CACR,SAAS,8EAA8E;CAC3F,CAAC;AAEF,MAAa,cAAcA,OAAAA,EAAE,OAAO;CAClC,GAAG,qBAAqB;CACxB,KAAKA,OAAAA,EAAE,QAAQ,CAAC,SAAS,qBAAqB;CAC/C,CAAC;AAGF,MAAa,eAAeA,OAAAA,EAAE,OAAO;CACnC,KAAKA,OAAAA,EAAE,QAAQ,CAAC,SAAS,kEAAkE;CAC3F,YAAYA,OAAAA,EAAE,MAAMA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS,8BAA8B;CACvE,KAAKA,OAAAA,EAAE,MAAMA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS,qCAAqC;CAEvE,KAAKA,OAAAA,EACF,QAAQ,CACR,QAAA,iBAAA,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,uBAAuB,MAAM;CACzD,qBAAqB,OAAO,mBAAmB,MAAM;CACtD,CAAC;AAGF,MAAa,sBAAsBA,OAAAA,EAAE,OAAO;CAC1C,MAAMA,OAAAA,EACH,QAAQ,CACR,SACC,sGACD;CACH,MAAMA,OAAAA,EAAE,QAAQ,CAAC,SAAS,4DAA4D;CACvF,CAAC;AAEF,MAAa,sBAAsBA,OAAAA,EAAE,mBAAmB,QAAQ;CAC9D,oBAAoB,OAAO,oBAAoB,MAAM;CACrD,oBAAoB,OAAO,0BAA0B,MAAM;CAC3D,oBAAoB,OAAO,4BAA4B,MAAM;CAC7D,oBAAoB,OAAO,uBAAuB,MAAM;CACxD,oBAAoB,OAAO,mBAAmB,MAAM;CAErD,CAAC;AAIF,MAAa,eAAeA,OAAAA,EACzB,OAAO;CACN,OAAOA,OAAAA,EAAE,SAAS,CAAC,UAAU;CAE7B,OAAO,YAAY,UAAU;CAC7B,QAAQ,qBAAqB,UAAU;CACvC,QAAQ,aAAa,UAAU;CAC/B,QAAQ,qBAAqB,UAAU;CACvC,OAAO,oBAAoB,UAAU;CACtC,CAAC,CACD,QACE,SAAA,aAAA,MACY,KAAK,OAAO,GAAA,aAAA,MACV,KAAK,UAAU,KAAK,OAAO,GAAA,aAAA,MAC3B,KAAK,MAAM,GAAA,aAAA,MACX,KAAK,MAAM,IACxB,GACF;CACE,SACE;CACF,MAAM,CAAC,+CAA+C;CACvD,CACF"}
|
|
1
|
+
{"version":3,"file":"sw-json.cjs","names":["z"],"sources":["../../../src/core/schemas/sw-json.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport * as defaults from \"../../defaults\";\nimport * as artifacts from \"./artifacts\";\nimport * as util from \"../util\";\n\nexport const remoteLocationSchema = z.object({\n registry: z.string().describe(\"name of the registry to use for package download\"),\n package: z\n .string()\n .describe(\"full package path in registry, e.g. 'common/jdk/21.0.2.13.1-{os}-{arch}.tgz\"),\n});\n\nexport const assetSchema = z.object({\n ...remoteLocationSchema.shape,\n url: z.string().describe(\"asset download URL\"),\n});\nexport type assetInfo = z.infer<typeof assetSchema>;\n\nexport const dockerSchema = z.object({\n tag: z.string().describe(\"full image tag to pull on backend side to execute this software\"),\n entrypoint: z.array(z.string()).describe(\"override image's entrypoint\"),\n cmd: z.array(z.string()).describe(\"command to be run in the container\"),\n\n pkg: z\n .string()\n .default(defaults.DOCKER_PLACEHOLDER_PKG)\n .describe(\n 'what to substitute in place of \"{pkg}\" variable in \"cmd\" (for artifacts with docker autogeneration)',\n ),\n});\nexport type dockerInfo = z.infer<typeof dockerSchema>;\n\nexport const runEnvironmentSchema = z.object({\n type: z.enum(artifacts.runEnvironmentTypes),\n ...remoteLocationSchema.shape,\n\n [\"r-version\"]: z.string().optional(),\n [\"python-version\"]: z.string().optional(),\n [\"java-version\"]: z.string().optional(),\n\n envVars: z\n .array(\n z\n .string()\n .regex(\n /=/,\n \"environment variable should be specified in format: <var-name>=<var-value>, i.e.: MY_ENV=value\",\n ),\n )\n .optional(),\n\n binDir: z.string(),\n});\nexport type runEnvInfo = z.infer<typeof runEnvironmentSchema>;\n\nexport const runDependencyJavaSchema = runEnvironmentSchema.extend({\n type: z.literal(\"java\"),\n name: z\n .string()\n .describe(\"name used to import this package as software dependency of tengo script\"),\n});\nexport type runEnvDependencyJava = z.infer<typeof runDependencyJavaSchema>;\n\nexport const runDependencyPythonSchema = runEnvironmentSchema.extend({\n type: z.literal(\"python\"),\n [\"python-version\"]: z.string(),\n name: z\n .string()\n .describe(\"name used to import this package as software dependency of tengo script\"),\n});\nexport type runEnvDependencyPython = z.infer<typeof runDependencyPythonSchema>;\n\nexport const runDependencyRSchema = runEnvironmentSchema.extend({\n type: z.literal(\"R\"),\n [\"r-version\"]: z.string(),\n name: z\n .string()\n .describe(\"name used to import this package as software dependency of tengo script\"),\n});\nexport type runEnvDependencyR = z.infer<typeof runDependencyRSchema>;\n\nexport type runEnvDependency = runEnvDependencyJava | runEnvDependencyPython | runEnvDependencyR;\n\nexport const commonPackageSettingsSchema = z.object({\n cmd: z.array(z.string()).min(1).describe(\"run given command, appended by args from workflow\"),\n\n envVars: z\n .array(\n z\n .string()\n .regex(\n /=/,\n \"full environment variable specification is required: <var-name>=<var-value>, e.g.: IS_CI=yes\",\n ),\n )\n .optional(),\n});\n\nexport const binaryPackageSchema = z.object({\n type: z.literal(\"binary\"),\n ...commonPackageSettingsSchema.shape,\n\n pkg: z\n .string()\n .optional()\n .describe(\"location of all package contents in Docker container (default: /app)\"),\n});\n\nexport const javaPackageSettingsSchema = z.object({\n type: z.literal(\"java\"),\n\n ...commonPackageSettingsSchema.shape,\n runEnv: runDependencyJavaSchema,\n});\n\nexport const pythonPackageSettingsSchema = z.object({\n type: z.literal(\"python\"),\n\n ...commonPackageSettingsSchema.shape,\n runEnv: runDependencyPythonSchema,\n\n toolset: z.string(),\n dependencies: z\n .record(z.string(), z.string())\n .describe(\n \"paths of files that describe dependencies for given toolset: say, requirements.txt for 'pip'\",\n ),\n});\n\nexport const rPackageSettingsSchema = z.object({\n type: z.literal(\"R\"),\n\n ...commonPackageSettingsSchema.shape,\n runEnv: runDependencyRSchema,\n\n toolset: z.string(),\n dependencies: z\n .record(z.string(), z.string())\n .describe(\n \"paths of files that describe dependencies for given toolset: say, requirements.txt for 'pip'\",\n ),\n});\n\nexport const condaPackageSchema = z.object({\n type: z.literal(\"conda\"),\n ...commonPackageSettingsSchema.shape,\n\n [\"micromamba-version\"]: z\n .string()\n .describe(\"version of micromamba to be used to operate with conda environments\"),\n [\"conda-root-dir\"]: z\n .string()\n .default(defaults.CONDA_DATA_LOCATION)\n .describe(\"root directory of conda environment inside package root\"),\n\n spec: z\n .string()\n .describe(\"location of spec.yaml describing conda environment, relative to package root.\"),\n});\n\nexport const remoteSoftwareSchema = z.union([\n remoteLocationSchema.extend(binaryPackageSchema.shape),\n remoteLocationSchema.extend(javaPackageSettingsSchema.shape),\n remoteLocationSchema.extend(pythonPackageSettingsSchema.shape),\n remoteLocationSchema.extend(rPackageSettingsSchema.shape),\n remoteLocationSchema.extend(condaPackageSchema.shape),\n]);\nexport type remoteSoftwareType = z.infer<typeof remoteSoftwareSchema>;\n\nexport const localLocationSchema = z.object({\n hash: z\n .string()\n .describe(\n \"hash of software directory. Makes deduplication to work properly when you actively develop software\",\n ),\n path: z.string().describe(\"absolute path to root directory of software on local host\"),\n});\n\nexport const localSoftwareSchema = z.discriminatedUnion(\"type\", [\n localLocationSchema.extend(binaryPackageSchema.shape),\n localLocationSchema.extend(javaPackageSettingsSchema.shape),\n localLocationSchema.extend(pythonPackageSettingsSchema.shape),\n localLocationSchema.extend(rPackageSettingsSchema.shape),\n localLocationSchema.extend(condaPackageSchema.shape),\n // Docker can be used 'as usual' without any special 'local' section magic\n]);\nexport type localSoftwareType = z.infer<typeof localSoftwareSchema>;\n\n// Full .sw.json file schema\nexport const swJsonSchema = z\n .object({\n isDev: z.boolean().optional(),\n\n asset: assetSchema.optional(),\n binary: remoteSoftwareSchema.optional(),\n docker: dockerSchema.optional(),\n runEnv: runEnvironmentSchema.optional(),\n local: localSoftwareSchema.optional(),\n })\n .refine(\n (data) =>\n util.toInt(data.runEnv) +\n util.toInt(data.binary || data.docker) + // allow both docker and binary to be set in single entrypoint\n util.toInt(data.asset) +\n util.toInt(data.local) ==\n 1,\n {\n message:\n \"entrypoint cannot point to several packages at once: choose 'environment', 'binary', 'asset', 'conda' or 'local'\",\n path: [\"environment | binary | asset | conda | local\"],\n },\n );\n\nexport type swJsonType = z.infer<typeof swJsonSchema> & {\n id: util.artifactID;\n};\n"],"mappings":";;;;;AAKA,MAAa,uBAAuBA,OAAAA,EAAE,OAAO;CAC3C,UAAUA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,kDAAkD;CAChF,SAASA,OAAAA,EACN,OAAO,CAAC,CACR,SAAS,6EAA6E;AAC3F,CAAC;AAED,MAAa,cAAcA,OAAAA,EAAE,OAAO;CAClC,GAAG,qBAAqB;CACxB,KAAKA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS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AA,aAAA,MAC1B,KAAK,KAAK,IAAA,aAAA,MACV,KAAK,KAAK,KACvB,GACF;CACE,SACE;CACF,MAAM,CAAC,8CAA8C;AACvD,CACF"}
|
|
@@ -105,6 +105,6 @@ const swJsonSchema = z.object({
|
|
|
105
105
|
path: ["environment | binary | asset | conda | local"]
|
|
106
106
|
});
|
|
107
107
|
//#endregion
|
|
108
|
-
export { swJsonSchema };
|
|
108
|
+
export { assetSchema, binaryPackageSchema, commonPackageSettingsSchema, condaPackageSchema, dockerSchema, javaPackageSettingsSchema, localLocationSchema, localSoftwareSchema, pythonPackageSettingsSchema, rPackageSettingsSchema, remoteLocationSchema, remoteSoftwareSchema, runDependencyJavaSchema, runDependencyPythonSchema, runDependencyRSchema, runEnvironmentSchema, swJsonSchema };
|
|
109
109
|
|
|
110
110
|
//# sourceMappingURL=sw-json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sw-json.js","names":["defaults.DOCKER_PLACEHOLDER_PKG","artifacts.runEnvironmentTypes","defaults.CONDA_DATA_LOCATION","util.toInt"],"sources":["../../../src/core/schemas/sw-json.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport * as defaults from \"../../defaults\";\nimport * as artifacts from \"./artifacts\";\nimport * as util from \"../util\";\n\nexport const remoteLocationSchema = z.object({\n registry: z.string().describe(\"name of the registry to use for package download\"),\n package: z\n .string()\n .describe(\"full package path in registry, e.g. 'common/jdk/21.0.2.13.1-{os}-{arch}.tgz\"),\n});\n\nexport const assetSchema = z.object({\n ...remoteLocationSchema.shape,\n url: z.string().describe(\"asset download URL\"),\n});\nexport type assetInfo = z.infer<typeof assetSchema>;\n\nexport const dockerSchema = z.object({\n tag: z.string().describe(\"full image tag to pull on backend side to execute this software\"),\n entrypoint: z.array(z.string()).describe(\"override image's entrypoint\"),\n cmd: z.array(z.string()).describe(\"command to be run in the container\"),\n\n pkg: z\n .string()\n .default(defaults.DOCKER_PLACEHOLDER_PKG)\n .describe(\n 'what to substitute in place of \"{pkg}\" variable in \"cmd\" (for artifacts with docker autogeneration)',\n ),\n});\nexport type dockerInfo = z.infer<typeof dockerSchema>;\n\nexport const runEnvironmentSchema = z.object({\n type: z.enum(artifacts.runEnvironmentTypes),\n ...remoteLocationSchema.shape,\n\n [\"r-version\"]: z.string().optional(),\n [\"python-version\"]: z.string().optional(),\n [\"java-version\"]: z.string().optional(),\n\n envVars: z\n .array(\n z\n .string()\n .regex(\n /=/,\n \"environment variable should be specified in format: <var-name>=<var-value>, i.e.: MY_ENV=value\",\n ),\n )\n .optional(),\n\n binDir: z.string(),\n});\nexport type runEnvInfo = z.infer<typeof runEnvironmentSchema>;\n\nexport const runDependencyJavaSchema = runEnvironmentSchema.extend({\n type: z.literal(\"java\"),\n name: z\n .string()\n .describe(\"name used to import this package as software dependency of tengo script\"),\n});\nexport type runEnvDependencyJava = z.infer<typeof runDependencyJavaSchema>;\n\nexport const runDependencyPythonSchema = runEnvironmentSchema.extend({\n type: z.literal(\"python\"),\n [\"python-version\"]: z.string(),\n name: z\n .string()\n .describe(\"name used to import this package as software dependency of tengo script\"),\n});\nexport type runEnvDependencyPython = z.infer<typeof runDependencyPythonSchema>;\n\nexport const runDependencyRSchema = runEnvironmentSchema.extend({\n type: z.literal(\"R\"),\n [\"r-version\"]: z.string(),\n name: z\n .string()\n .describe(\"name used to import this package as software dependency of tengo script\"),\n});\nexport type runEnvDependencyR = z.infer<typeof runDependencyRSchema>;\n\nexport type runEnvDependency = runEnvDependencyJava | runEnvDependencyPython | runEnvDependencyR;\n\nexport const commonPackageSettingsSchema = z.object({\n cmd: z.array(z.string()).min(1).describe(\"run given command, appended by args from workflow\"),\n\n envVars: z\n .array(\n z\n .string()\n .regex(\n /=/,\n \"full environment variable specification is required: <var-name>=<var-value>, e.g.: IS_CI=yes\",\n ),\n )\n .optional(),\n});\n\nexport const binaryPackageSchema = z.object({\n type: z.literal(\"binary\"),\n ...commonPackageSettingsSchema.shape,\n\n pkg: z\n .string()\n .optional()\n .describe(\"location of all package contents in Docker container (default: /app)\"),\n});\n\nexport const javaPackageSettingsSchema = z.object({\n type: z.literal(\"java\"),\n\n ...commonPackageSettingsSchema.shape,\n runEnv: runDependencyJavaSchema,\n});\n\nexport const pythonPackageSettingsSchema = z.object({\n type: z.literal(\"python\"),\n\n ...commonPackageSettingsSchema.shape,\n runEnv: runDependencyPythonSchema,\n\n toolset: z.string(),\n dependencies: z\n .record(z.string(), z.string())\n .describe(\n \"paths of files that describe dependencies for given toolset: say, requirements.txt for 'pip'\",\n ),\n});\n\nexport const rPackageSettingsSchema = z.object({\n type: z.literal(\"R\"),\n\n ...commonPackageSettingsSchema.shape,\n runEnv: runDependencyRSchema,\n\n toolset: z.string(),\n dependencies: z\n .record(z.string(), z.string())\n .describe(\n \"paths of files that describe dependencies for given toolset: say, requirements.txt for 'pip'\",\n ),\n});\n\nexport const condaPackageSchema = z.object({\n type: z.literal(\"conda\"),\n ...commonPackageSettingsSchema.shape,\n\n [\"micromamba-version\"]: z\n .string()\n .describe(\"version of micromamba to be used to operate with conda environments\"),\n [\"conda-root-dir\"]: z\n .string()\n .default(defaults.CONDA_DATA_LOCATION)\n .describe(\"root directory of conda environment inside package root\"),\n\n spec: z\n .string()\n .describe(\"location of spec.yaml describing conda environment, relative to package root.\"),\n});\n\nexport const remoteSoftwareSchema = z.union([\n remoteLocationSchema.extend(binaryPackageSchema.shape),\n remoteLocationSchema.extend(javaPackageSettingsSchema.shape),\n remoteLocationSchema.extend(pythonPackageSettingsSchema.shape),\n remoteLocationSchema.extend(rPackageSettingsSchema.shape),\n remoteLocationSchema.extend(condaPackageSchema.shape),\n]);\nexport type remoteSoftwareType = z.infer<typeof remoteSoftwareSchema>;\n\nexport const localLocationSchema = z.object({\n hash: z\n .string()\n .describe(\n \"hash of software directory. Makes deduplication to work properly when you actively develop software\",\n ),\n path: z.string().describe(\"absolute path to root directory of software on local host\"),\n});\n\nexport const localSoftwareSchema = z.discriminatedUnion(\"type\", [\n localLocationSchema.extend(binaryPackageSchema.shape),\n localLocationSchema.extend(javaPackageSettingsSchema.shape),\n localLocationSchema.extend(pythonPackageSettingsSchema.shape),\n localLocationSchema.extend(rPackageSettingsSchema.shape),\n localLocationSchema.extend(condaPackageSchema.shape),\n // Docker can be used 'as usual' without any special 'local' section magic\n]);\nexport type localSoftwareType = z.infer<typeof localSoftwareSchema>;\n\n// Full .sw.json file schema\nexport const swJsonSchema = z\n .object({\n isDev: z.boolean().optional(),\n\n asset: assetSchema.optional(),\n binary: remoteSoftwareSchema.optional(),\n docker: dockerSchema.optional(),\n runEnv: runEnvironmentSchema.optional(),\n local: localSoftwareSchema.optional(),\n })\n .refine(\n (data) =>\n util.toInt(data.runEnv) +\n util.toInt(data.binary || data.docker) + // allow both docker and binary to be set in single entrypoint\n util.toInt(data.asset) +\n util.toInt(data.local) ==\n 1,\n {\n message:\n \"entrypoint cannot point to several packages at once: choose 'environment', 'binary', 'asset', 'conda' or 'local'\",\n path: [\"environment | binary | asset | conda | local\"],\n },\n );\n\nexport type swJsonType = z.infer<typeof swJsonSchema> & {\n id: util.artifactID;\n};\n"],"mappings":";;;;;AAKA,MAAa,uBAAuB,EAAE,OAAO;CAC3C,UAAU,EAAE,QAAQ,CAAC,SAAS,mDAAmD;CACjF,SAAS,EACN,QAAQ,CACR,SAAS,8EAA8E;CAC3F,CAAC;AAEF,MAAa,cAAc,EAAE,OAAO;CAClC,GAAG,qBAAqB;CACxB,KAAK,EAAE,QAAQ,CAAC,SAAS,qBAAqB;CAC/C,CAAC;AAGF,MAAa,eAAe,EAAE,OAAO;CACnC,KAAK,EAAE,QAAQ,CAAC,SAAS,kEAAkE;CAC3F,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,SAAS,8BAA8B;CACvE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,SAAS,qCAAqC;CAEvE,KAAK,EACF,QAAQ,CACR,QAAQA,uBAAgC,CACxC,SACC,0GACD;CACJ,CAAC;AAGF,MAAa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AAIF,MAAa,eAAe,EACzB,OAAO;CACN,OAAO,EAAE,SAAS,CAAC,UAAU;CAE7B,OAAO,YAAY,UAAU;CAC7B,QAAQ,qBAAqB,UAAU;CACvC,QAAQ,aAAa,UAAU;CAC/B,QAAQ,qBAAqB,UAAU;CACvC,OAAO,oBAAoB,UAAU;CACtC,CAAC,CACD,QACE,SACCC,MAAW,KAAK,OAAO,GACrBA,MAAW,KAAK,UAAU,KAAK,OAAO,GACtCA,MAAW,KAAK,MAAM,GACtBA,MAAW,KAAK,MAAM,IACxB,GACF;CACE,SACE;CACF,MAAM,CAAC,+CAA+C;CACvD,CACF"}
|
|
1
|
+
{"version":3,"file":"sw-json.js","names":["defaults.DOCKER_PLACEHOLDER_PKG","artifacts.runEnvironmentTypes","defaults.CONDA_DATA_LOCATION","util.toInt"],"sources":["../../../src/core/schemas/sw-json.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport * as defaults from \"../../defaults\";\nimport * as artifacts from \"./artifacts\";\nimport * as util from \"../util\";\n\nexport const remoteLocationSchema = z.object({\n registry: z.string().describe(\"name of the registry to use for package download\"),\n package: z\n .string()\n .describe(\"full package path in registry, e.g. 'common/jdk/21.0.2.13.1-{os}-{arch}.tgz\"),\n});\n\nexport const assetSchema = z.object({\n ...remoteLocationSchema.shape,\n url: z.string().describe(\"asset download URL\"),\n});\nexport type assetInfo = z.infer<typeof assetSchema>;\n\nexport const dockerSchema = z.object({\n tag: z.string().describe(\"full image tag to pull on backend side to execute this software\"),\n entrypoint: z.array(z.string()).describe(\"override image's entrypoint\"),\n cmd: z.array(z.string()).describe(\"command to be run in the container\"),\n\n pkg: z\n .string()\n .default(defaults.DOCKER_PLACEHOLDER_PKG)\n .describe(\n 'what to substitute in place of \"{pkg}\" variable in \"cmd\" (for artifacts with docker autogeneration)',\n ),\n});\nexport type dockerInfo = z.infer<typeof dockerSchema>;\n\nexport const runEnvironmentSchema = z.object({\n type: z.enum(artifacts.runEnvironmentTypes),\n ...remoteLocationSchema.shape,\n\n [\"r-version\"]: z.string().optional(),\n [\"python-version\"]: z.string().optional(),\n [\"java-version\"]: z.string().optional(),\n\n envVars: z\n .array(\n z\n .string()\n .regex(\n /=/,\n \"environment variable should be specified in format: <var-name>=<var-value>, i.e.: MY_ENV=value\",\n ),\n )\n .optional(),\n\n binDir: z.string(),\n});\nexport type runEnvInfo = z.infer<typeof runEnvironmentSchema>;\n\nexport const runDependencyJavaSchema = runEnvironmentSchema.extend({\n type: z.literal(\"java\"),\n name: z\n .string()\n .describe(\"name used to import this package as software dependency of tengo script\"),\n});\nexport type runEnvDependencyJava = z.infer<typeof runDependencyJavaSchema>;\n\nexport const runDependencyPythonSchema = runEnvironmentSchema.extend({\n type: z.literal(\"python\"),\n [\"python-version\"]: z.string(),\n name: z\n .string()\n .describe(\"name used to import this package as software dependency of tengo script\"),\n});\nexport type runEnvDependencyPython = z.infer<typeof runDependencyPythonSchema>;\n\nexport const runDependencyRSchema = runEnvironmentSchema.extend({\n type: z.literal(\"R\"),\n [\"r-version\"]: z.string(),\n name: z\n .string()\n .describe(\"name used to import this package as software dependency of tengo script\"),\n});\nexport type runEnvDependencyR = z.infer<typeof runDependencyRSchema>;\n\nexport type runEnvDependency = runEnvDependencyJava | runEnvDependencyPython | runEnvDependencyR;\n\nexport const commonPackageSettingsSchema = z.object({\n cmd: z.array(z.string()).min(1).describe(\"run given command, appended by args from workflow\"),\n\n envVars: z\n .array(\n z\n .string()\n .regex(\n /=/,\n \"full environment variable specification is required: <var-name>=<var-value>, e.g.: IS_CI=yes\",\n ),\n )\n .optional(),\n});\n\nexport const binaryPackageSchema = z.object({\n type: z.literal(\"binary\"),\n ...commonPackageSettingsSchema.shape,\n\n pkg: z\n .string()\n .optional()\n .describe(\"location of all package contents in Docker container (default: /app)\"),\n});\n\nexport const javaPackageSettingsSchema = z.object({\n type: z.literal(\"java\"),\n\n ...commonPackageSettingsSchema.shape,\n runEnv: runDependencyJavaSchema,\n});\n\nexport const pythonPackageSettingsSchema = z.object({\n type: z.literal(\"python\"),\n\n ...commonPackageSettingsSchema.shape,\n runEnv: runDependencyPythonSchema,\n\n toolset: z.string(),\n dependencies: z\n .record(z.string(), z.string())\n .describe(\n \"paths of files that describe dependencies for given toolset: say, requirements.txt for 'pip'\",\n ),\n});\n\nexport const rPackageSettingsSchema = z.object({\n type: z.literal(\"R\"),\n\n ...commonPackageSettingsSchema.shape,\n runEnv: runDependencyRSchema,\n\n toolset: z.string(),\n dependencies: z\n .record(z.string(), z.string())\n .describe(\n \"paths of files that describe dependencies for given toolset: say, requirements.txt for 'pip'\",\n ),\n});\n\nexport const condaPackageSchema = z.object({\n type: z.literal(\"conda\"),\n ...commonPackageSettingsSchema.shape,\n\n [\"micromamba-version\"]: z\n .string()\n .describe(\"version of micromamba to be used to operate with conda environments\"),\n [\"conda-root-dir\"]: z\n .string()\n .default(defaults.CONDA_DATA_LOCATION)\n .describe(\"root directory of conda environment inside package root\"),\n\n spec: z\n .string()\n .describe(\"location of spec.yaml describing conda environment, relative to package root.\"),\n});\n\nexport const remoteSoftwareSchema = z.union([\n remoteLocationSchema.extend(binaryPackageSchema.shape),\n remoteLocationSchema.extend(javaPackageSettingsSchema.shape),\n remoteLocationSchema.extend(pythonPackageSettingsSchema.shape),\n remoteLocationSchema.extend(rPackageSettingsSchema.shape),\n remoteLocationSchema.extend(condaPackageSchema.shape),\n]);\nexport type remoteSoftwareType = z.infer<typeof remoteSoftwareSchema>;\n\nexport const localLocationSchema = z.object({\n hash: z\n .string()\n .describe(\n \"hash of software directory. Makes deduplication to work properly when you actively develop software\",\n ),\n path: z.string().describe(\"absolute path to root directory of software on local host\"),\n});\n\nexport const localSoftwareSchema = z.discriminatedUnion(\"type\", [\n localLocationSchema.extend(binaryPackageSchema.shape),\n localLocationSchema.extend(javaPackageSettingsSchema.shape),\n localLocationSchema.extend(pythonPackageSettingsSchema.shape),\n localLocationSchema.extend(rPackageSettingsSchema.shape),\n localLocationSchema.extend(condaPackageSchema.shape),\n // Docker can be used 'as usual' without any special 'local' section magic\n]);\nexport type localSoftwareType = z.infer<typeof localSoftwareSchema>;\n\n// Full .sw.json file schema\nexport const swJsonSchema = z\n .object({\n isDev: z.boolean().optional(),\n\n asset: assetSchema.optional(),\n binary: remoteSoftwareSchema.optional(),\n docker: dockerSchema.optional(),\n runEnv: runEnvironmentSchema.optional(),\n local: localSoftwareSchema.optional(),\n })\n .refine(\n (data) =>\n util.toInt(data.runEnv) +\n util.toInt(data.binary || data.docker) + // allow both docker and binary to be set in single entrypoint\n util.toInt(data.asset) +\n util.toInt(data.local) ==\n 1,\n {\n message:\n \"entrypoint cannot point to several packages at once: choose 'environment', 'binary', 'asset', 'conda' or 'local'\",\n path: [\"environment | binary | asset | conda | local\"],\n },\n );\n\nexport type swJsonType = z.infer<typeof swJsonSchema> & {\n id: util.artifactID;\n};\n"],"mappings":";;;;;AAKA,MAAa,uBAAuB,EAAE,OAAO;CAC3C,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,kDAAkD;CAChF,SAAS,EACN,OAAO,CAAC,CACR,SAAS,6EAA6E;AAC3F,CAAC;AAED,MAAa,cAAc,EAAE,OAAO;CAClC,GAAG,qBAAqB;CACxB,KAAK,EAAE,OAAO,CAAC,CAAC,SAAS,oBAAoB;AAC/C,CAAC;AAGD,MAAa,eAAe,EAAE,OAAO;CACnC,KAAK,EAAE,OAAO,CAAC,CAAC,SAAS,iEAAiE;CAC1F,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,6BAA6B;CACtE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,oCAAoC;CAEtE,KAAK,EACF,OAAO,CAAC,CACR,QAAQA,sBAA+B,CAAC,CACxC,SACC,yGACF;AACJ,CAAC;AAGD,MAAa,uBAAuB,EAAE,OAAO;CAC3C,MAAM,EAAE,KAAKC,mBAA6B;CAC1C,GAAG,qBAAqB;EAEvB,cAAc,EAAE,OAAO,CAAC,CAAC,SAAS;E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O;CACN,OAAO,EAAE,QAAQ,CAAC,CAAC,SAAS;CAE5B,OAAO,YAAY,SAAS;CAC5B,QAAQ,qBAAqB,SAAS;CACtC,QAAQ,aAAa,SAAS;CAC9B,QAAQ,qBAAqB,SAAS;CACtC,OAAO,oBAAoB,SAAS;AACtC,CAAC,CAAC,CACD,QACE,SACCC,MAAW,KAAK,MAAM,IACpBA,MAAW,KAAK,UAAU,KAAK,MAAM,IACrCA,MAAW,KAAK,KAAK,IACrBA,MAAW,KAAK,KAAK,KACvB,GACF;CACE,SACE;CACF,MAAM,CAAC,8CAA8C;AACvD,CACF"}
|
package/dist/core/storage.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_util = require("./util.cjs");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
|
-
node_path = require_runtime.__toESM(node_path);
|
|
4
|
+
node_path = require_runtime.__toESM(node_path, 1);
|
|
5
5
|
let node_path_posix = require("node:path/posix");
|
|
6
|
-
node_path_posix = require_runtime.__toESM(node_path_posix);
|
|
6
|
+
node_path_posix = require_runtime.__toESM(node_path_posix, 1);
|
|
7
7
|
let _aws_sdk_client_s3 = require("@aws-sdk/client-s3");
|
|
8
8
|
let _aws_sdk_lib_storage = require("@aws-sdk/lib-storage");
|
|
9
9
|
//#region src/core/storage.ts
|
|
@@ -29,6 +29,9 @@ async function newS3(options, bucket) {
|
|
|
29
29
|
return client;
|
|
30
30
|
}
|
|
31
31
|
var S3Storage = class {
|
|
32
|
+
client;
|
|
33
|
+
bucket;
|
|
34
|
+
root;
|
|
32
35
|
constructor(client, bucket, root = "") {
|
|
33
36
|
this.client = client;
|
|
34
37
|
this.bucket = bucket;
|
|
@@ -81,6 +84,7 @@ async function initByUrl(address, pkgRoot) {
|
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
//#endregion
|
|
87
|
+
exports.S3Storage = S3Storage;
|
|
84
88
|
exports.initByUrl = initByUrl;
|
|
85
89
|
|
|
86
90
|
//# sourceMappingURL=storage.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.cjs","names":["S3","pathPosix","Upload","path"],"sources":["../../src/core/storage.ts"],"sourcesContent":["import pathPosix from \"node:path/posix\";\nimport { S3 } from \"@aws-sdk/client-s3\";\nimport { Upload } from \"@aws-sdk/lib-storage\";\nimport path from \"node:path\";\nimport * as util from \"./util\";\nimport type { Readable } from \"node:stream\";\n\nexport const supportedTypes = [\"S3\"] as const; // add other types when we support them\nexport type storageType = (typeof supportedTypes)[number];\n\nexport function typeToURLScheme(sType: storageType): string {\n switch (sType) {\n case \"S3\":\n return \"s3\";\n default:\n util.assertNever(sType);\n throw new Error(\"no schema defined for storage type\"); // just to calm down TS type analyzer\n }\n}\n\nexport interface RegistryStorage {\n exists(file: string): Promise<boolean>;\n putFile(file: string, data: Buffer | Readable): Promise<void>;\n}\n\nasync function objectExists(client: S3, bucket: string, key: string): Promise<boolean> {\n try {\n await client.headObject({\n Bucket: bucket,\n Key: key,\n });\n\n return true;\n } catch (error) {\n if (error instanceof Error && error.name === \"NotFound\") {\n return false;\n }\n\n throw util.wrapErr(error, `failed to check if object exists in S3 bucket ${bucket}`);\n }\n}\n\nasync function newS3(\n options: NonNullable<ConstructorParameters<typeof S3>[0]>,\n bucket: string,\n): Promise<S3> {\n const client = new S3(options);\n\n try {\n await objectExists(client, bucket, \"/\");\n } catch (error) {\n throw util.CLIError(\n `credentials given to package builder do not have access to S3 bucket '${bucket}': ${error}`,\n );\n }\n\n return client;\n}\n\nexport class S3Storage implements RegistryStorage {\n constructor(\n public readonly client: S3,\n public readonly bucket: string,\n public readonly root: string = \"\",\n ) {}\n\n async exists(file: string): Promise<boolean> {\n return objectExists(this.client, this.bucket, pathPosix.join(this.root, file));\n }\n\n async putFile(file: string, data: Buffer | Readable): Promise<void> {\n try {\n const upload = new Upload({\n client: this.client,\n params: {\n Bucket: this.bucket,\n Key: pathPosix.join(this.root, file),\n Body: data,\n },\n });\n\n await upload.done();\n } catch (e) {\n throw util.wrapErr(e, `failed to put object into S3 bucket ${this.bucket}`);\n }\n }\n}\n\nexport async function initByUrl(address: string, pkgRoot: string): Promise<RegistryStorage> {\n if (address === \"\") {\n throw util.CLIError(`Empty registry storage address`);\n }\n\n try {\n const url = new URL(address, `file:${pkgRoot.split(path.sep).join(pathPosix.sep)}/`);\n switch (url.protocol) {\n case \"s3:\": {\n const s3Options: NonNullable<ConstructorParameters<typeof S3>[0]> = {};\n const s3Region = url.searchParams.get(\"region\");\n if (s3Region) s3Options.region = s3Region;\n const s3Bucket = url.hostname;\n const s3KeyPrefix = util.trimPrefix(url.pathname, \"/\");\n const s3Client = await newS3(s3Options, s3Bucket);\n return new S3Storage(s3Client, s3Bucket, s3KeyPrefix);\n }\n case \"s3e:\": {\n const s3eOptions: NonNullable<ConstructorParameters<typeof S3>[0]> = {};\n const s3eRegion = url.searchParams.get(\"region\");\n if (s3eRegion) s3eOptions.region = s3eRegion;\n\n const s3ePath = url.pathname.split(\"/\").slice(1); // '/bucket/keyPrefix' -> ['', 'bucket', 'keyPrefix'] -> ['bucket', 'keyPrefix']\n const s3eBucket = s3ePath[0];\n const s3eKeyPrefix = s3ePath.length > 1 ? util.trimPrefix(s3ePath[1], \"/\") : \"\";\n const s3eClient = await newS3(s3eOptions, s3eBucket);\n return new S3Storage(s3eClient, s3eBucket, s3eKeyPrefix);\n }\n default:\n throw util.CLIError(\n `Protocol ${url.protocol} is not supported for software registries yet. Use your own tooling for package upload`,\n );\n }\n } catch (e) {\n throw util.wrapErr(e, `failed to init storage driver from URL`);\n }\n}\n"],"mappings":";;;;;;;;;AAyBA,eAAe,aAAa,QAAY,QAAgB,KAA+B;
|
|
1
|
+
{"version":3,"file":"storage.cjs","names":["S3","pathPosix","Upload","path"],"sources":["../../src/core/storage.ts"],"sourcesContent":["import pathPosix from \"node:path/posix\";\nimport { S3 } from \"@aws-sdk/client-s3\";\nimport { Upload } from \"@aws-sdk/lib-storage\";\nimport path from \"node:path\";\nimport * as util from \"./util\";\nimport type { Readable } from \"node:stream\";\n\nexport const supportedTypes = [\"S3\"] as const; // add other types when we support them\nexport type storageType = (typeof supportedTypes)[number];\n\nexport function typeToURLScheme(sType: storageType): string {\n switch (sType) {\n case \"S3\":\n return \"s3\";\n default:\n util.assertNever(sType);\n throw new Error(\"no schema defined for storage type\"); // just to calm down TS type analyzer\n }\n}\n\nexport interface RegistryStorage {\n exists(file: string): Promise<boolean>;\n putFile(file: string, data: Buffer | Readable): Promise<void>;\n}\n\nasync function objectExists(client: S3, bucket: string, key: string): Promise<boolean> {\n try {\n await client.headObject({\n Bucket: bucket,\n Key: key,\n });\n\n return true;\n } catch (error) {\n if (error instanceof Error && error.name === \"NotFound\") {\n return false;\n }\n\n throw util.wrapErr(error, `failed to check if object exists in S3 bucket ${bucket}`);\n }\n}\n\nasync function newS3(\n options: NonNullable<ConstructorParameters<typeof S3>[0]>,\n bucket: string,\n): Promise<S3> {\n const client = new S3(options);\n\n try {\n await objectExists(client, bucket, \"/\");\n } catch (error) {\n throw util.CLIError(\n `credentials given to package builder do not have access to S3 bucket '${bucket}': ${error}`,\n );\n }\n\n return client;\n}\n\nexport class S3Storage implements RegistryStorage {\n constructor(\n public readonly client: S3,\n public readonly bucket: string,\n public readonly root: string = \"\",\n ) {}\n\n async exists(file: string): Promise<boolean> {\n return objectExists(this.client, this.bucket, pathPosix.join(this.root, file));\n }\n\n async putFile(file: string, data: Buffer | Readable): Promise<void> {\n try {\n const upload = new Upload({\n client: this.client,\n params: {\n Bucket: this.bucket,\n Key: pathPosix.join(this.root, file),\n Body: data,\n },\n });\n\n await upload.done();\n } catch (e) {\n throw util.wrapErr(e, `failed to put object into S3 bucket ${this.bucket}`);\n }\n }\n}\n\nexport async function initByUrl(address: string, pkgRoot: string): Promise<RegistryStorage> {\n if (address === \"\") {\n throw util.CLIError(`Empty registry storage address`);\n }\n\n try {\n const url = new URL(address, `file:${pkgRoot.split(path.sep).join(pathPosix.sep)}/`);\n switch (url.protocol) {\n case \"s3:\": {\n const s3Options: NonNullable<ConstructorParameters<typeof S3>[0]> = {};\n const s3Region = url.searchParams.get(\"region\");\n if (s3Region) s3Options.region = s3Region;\n const s3Bucket = url.hostname;\n const s3KeyPrefix = util.trimPrefix(url.pathname, \"/\");\n const s3Client = await newS3(s3Options, s3Bucket);\n return new S3Storage(s3Client, s3Bucket, s3KeyPrefix);\n }\n case \"s3e:\": {\n const s3eOptions: NonNullable<ConstructorParameters<typeof S3>[0]> = {};\n const s3eRegion = url.searchParams.get(\"region\");\n if (s3eRegion) s3eOptions.region = s3eRegion;\n\n const s3ePath = url.pathname.split(\"/\").slice(1); // '/bucket/keyPrefix' -> ['', 'bucket', 'keyPrefix'] -> ['bucket', 'keyPrefix']\n const s3eBucket = s3ePath[0];\n const s3eKeyPrefix = s3ePath.length > 1 ? util.trimPrefix(s3ePath[1], \"/\") : \"\";\n const s3eClient = await newS3(s3eOptions, s3eBucket);\n return new S3Storage(s3eClient, s3eBucket, s3eKeyPrefix);\n }\n default:\n throw util.CLIError(\n `Protocol ${url.protocol} is not supported for software registries yet. Use your own tooling for package upload`,\n );\n }\n } catch (e) {\n throw util.wrapErr(e, `failed to init storage driver from URL`);\n }\n}\n"],"mappings":";;;;;;;;;AAyBA,eAAe,aAAa,QAAY,QAAgB,KAA+B;CACrF,IAAI;EACF,MAAM,OAAO,WAAW;GACtB,QAAQ;GACR,KAAK;EACP,CAAC;EAED,OAAO;CACT,SAAS,OAAO;EACd,IAAI,iBAAiB,SAAS,MAAM,SAAS,YAC3C,OAAO;EAGT,MAAA,aAAA,QAAmB,OAAO,iDAAiD,QAAQ;CACrF;AACF;AAEA,eAAe,MACb,SACA,QACa;CACb,MAAM,SAAS,IAAIA,mBAAAA,GAAG,OAAO;CAE7B,IAAI;EACF,MAAM,aAAa,QAAQ,QAAQ,GAAG;CACxC,SAAS,OAAO;EACd,MAAA,aAAA,SACE,yEAAyE,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AAS;IAEnC,MAAM,UAAU,IAAI,SAAS,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,MAAM,YAAY,QAAQ;IAC1B,MAAM,eAAe,QAAQ,SAAS,IAAA,aAAA,WAAoB,QAAQ,IAAI,GAAG,IAAI;IAE7E,OAAO,IAAI,UAAU,MADG,MAAM,YAAY,SAAS,GACnB,WAAW,YAAY;GACzD;GACA,SACE,MAAA,aAAA,SACE,YAAY,IAAI,SAAS,uFAC3B;EACJ;CACF,SAAS,GAAG;EACV,MAAA,aAAA,QAAmB,GAAG,wCAAwC;CAChE;AACF"}
|
package/dist/core/storage.js
CHANGED
|
@@ -26,6 +26,9 @@ async function newS3(options, bucket) {
|
|
|
26
26
|
return client;
|
|
27
27
|
}
|
|
28
28
|
var S3Storage = class {
|
|
29
|
+
client;
|
|
30
|
+
bucket;
|
|
31
|
+
root;
|
|
29
32
|
constructor(client, bucket, root = "") {
|
|
30
33
|
this.client = client;
|
|
31
34
|
this.bucket = bucket;
|
|
@@ -78,6 +81,6 @@ async function initByUrl(address, pkgRoot) {
|
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
//#endregion
|
|
81
|
-
export { initByUrl };
|
|
84
|
+
export { S3Storage, initByUrl };
|
|
82
85
|
|
|
83
86
|
//# sourceMappingURL=storage.js.map
|
package/dist/core/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","names":["util.wrapErr","util.CLIError","util.trimPrefix"],"sources":["../../src/core/storage.ts"],"sourcesContent":["import pathPosix from \"node:path/posix\";\nimport { S3 } from \"@aws-sdk/client-s3\";\nimport { Upload } from \"@aws-sdk/lib-storage\";\nimport path from \"node:path\";\nimport * as util from \"./util\";\nimport type { Readable } from \"node:stream\";\n\nexport const supportedTypes = [\"S3\"] as const; // add other types when we support them\nexport type storageType = (typeof supportedTypes)[number];\n\nexport function typeToURLScheme(sType: storageType): string {\n switch (sType) {\n case \"S3\":\n return \"s3\";\n default:\n util.assertNever(sType);\n throw new Error(\"no schema defined for storage type\"); // just to calm down TS type analyzer\n }\n}\n\nexport interface RegistryStorage {\n exists(file: string): Promise<boolean>;\n putFile(file: string, data: Buffer | Readable): Promise<void>;\n}\n\nasync function objectExists(client: S3, bucket: string, key: string): Promise<boolean> {\n try {\n await client.headObject({\n Bucket: bucket,\n Key: key,\n });\n\n return true;\n } catch (error) {\n if (error instanceof Error && error.name === \"NotFound\") {\n return false;\n }\n\n throw util.wrapErr(error, `failed to check if object exists in S3 bucket ${bucket}`);\n }\n}\n\nasync function newS3(\n options: NonNullable<ConstructorParameters<typeof S3>[0]>,\n bucket: string,\n): Promise<S3> {\n const client = new S3(options);\n\n try {\n await objectExists(client, bucket, \"/\");\n } catch (error) {\n throw util.CLIError(\n `credentials given to package builder do not have access to S3 bucket '${bucket}': ${error}`,\n );\n }\n\n return client;\n}\n\nexport class S3Storage implements RegistryStorage {\n constructor(\n public readonly client: S3,\n public readonly bucket: string,\n public readonly root: string = \"\",\n ) {}\n\n async exists(file: string): Promise<boolean> {\n return objectExists(this.client, this.bucket, pathPosix.join(this.root, file));\n }\n\n async putFile(file: string, data: Buffer | Readable): Promise<void> {\n try {\n const upload = new Upload({\n client: this.client,\n params: {\n Bucket: this.bucket,\n Key: pathPosix.join(this.root, file),\n Body: data,\n },\n });\n\n await upload.done();\n } catch (e) {\n throw util.wrapErr(e, `failed to put object into S3 bucket ${this.bucket}`);\n }\n }\n}\n\nexport async function initByUrl(address: string, pkgRoot: string): Promise<RegistryStorage> {\n if (address === \"\") {\n throw util.CLIError(`Empty registry storage address`);\n }\n\n try {\n const url = new URL(address, `file:${pkgRoot.split(path.sep).join(pathPosix.sep)}/`);\n switch (url.protocol) {\n case \"s3:\": {\n const s3Options: NonNullable<ConstructorParameters<typeof S3>[0]> = {};\n const s3Region = url.searchParams.get(\"region\");\n if (s3Region) s3Options.region = s3Region;\n const s3Bucket = url.hostname;\n const s3KeyPrefix = util.trimPrefix(url.pathname, \"/\");\n const s3Client = await newS3(s3Options, s3Bucket);\n return new S3Storage(s3Client, s3Bucket, s3KeyPrefix);\n }\n case \"s3e:\": {\n const s3eOptions: NonNullable<ConstructorParameters<typeof S3>[0]> = {};\n const s3eRegion = url.searchParams.get(\"region\");\n if (s3eRegion) s3eOptions.region = s3eRegion;\n\n const s3ePath = url.pathname.split(\"/\").slice(1); // '/bucket/keyPrefix' -> ['', 'bucket', 'keyPrefix'] -> ['bucket', 'keyPrefix']\n const s3eBucket = s3ePath[0];\n const s3eKeyPrefix = s3ePath.length > 1 ? util.trimPrefix(s3ePath[1], \"/\") : \"\";\n const s3eClient = await newS3(s3eOptions, s3eBucket);\n return new S3Storage(s3eClient, s3eBucket, s3eKeyPrefix);\n }\n default:\n throw util.CLIError(\n `Protocol ${url.protocol} is not supported for software registries yet. Use your own tooling for package upload`,\n );\n }\n } catch (e) {\n throw util.wrapErr(e, `failed to init storage driver from URL`);\n }\n}\n"],"mappings":";;;;;;AAyBA,eAAe,aAAa,QAAY,QAAgB,KAA+B;
|
|
1
|
+
{"version":3,"file":"storage.js","names":["util.wrapErr","util.CLIError","util.trimPrefix"],"sources":["../../src/core/storage.ts"],"sourcesContent":["import pathPosix from \"node:path/posix\";\nimport { S3 } from \"@aws-sdk/client-s3\";\nimport { Upload } from \"@aws-sdk/lib-storage\";\nimport path from \"node:path\";\nimport * as util from \"./util\";\nimport type { Readable } from \"node:stream\";\n\nexport const supportedTypes = [\"S3\"] as const; // add other types when we support them\nexport type storageType = (typeof supportedTypes)[number];\n\nexport function typeToURLScheme(sType: storageType): string {\n switch (sType) {\n case \"S3\":\n return \"s3\";\n default:\n util.assertNever(sType);\n throw new Error(\"no schema defined for storage type\"); // just to calm down TS type analyzer\n }\n}\n\nexport interface RegistryStorage {\n exists(file: string): Promise<boolean>;\n putFile(file: string, data: Buffer | Readable): Promise<void>;\n}\n\nasync function objectExists(client: S3, bucket: string, key: string): Promise<boolean> {\n try {\n await client.headObject({\n Bucket: bucket,\n Key: key,\n });\n\n return true;\n } catch (error) {\n if (error instanceof Error && error.name === \"NotFound\") {\n return false;\n }\n\n throw util.wrapErr(error, `failed to check if object exists in S3 bucket ${bucket}`);\n }\n}\n\nasync function newS3(\n options: NonNullable<ConstructorParameters<typeof S3>[0]>,\n bucket: string,\n): Promise<S3> {\n const client = new S3(options);\n\n try {\n await objectExists(client, bucket, \"/\");\n } catch (error) {\n throw util.CLIError(\n `credentials given to package builder do not have access to S3 bucket '${bucket}': ${error}`,\n );\n }\n\n return client;\n}\n\nexport class S3Storage implements RegistryStorage {\n constructor(\n public readonly client: S3,\n public readonly bucket: string,\n public readonly root: string = \"\",\n ) {}\n\n async exists(file: string): Promise<boolean> {\n return objectExists(this.client, this.bucket, pathPosix.join(this.root, file));\n }\n\n async putFile(file: string, data: Buffer | Readable): Promise<void> {\n try {\n const upload = new Upload({\n client: this.client,\n params: {\n Bucket: this.bucket,\n Key: pathPosix.join(this.root, file),\n Body: data,\n },\n });\n\n await upload.done();\n } catch (e) {\n throw util.wrapErr(e, `failed to put object into S3 bucket ${this.bucket}`);\n }\n }\n}\n\nexport async function initByUrl(address: string, pkgRoot: string): Promise<RegistryStorage> {\n if (address === \"\") {\n throw util.CLIError(`Empty registry storage address`);\n }\n\n try {\n const url = new URL(address, `file:${pkgRoot.split(path.sep).join(pathPosix.sep)}/`);\n switch (url.protocol) {\n case \"s3:\": {\n const s3Options: NonNullable<ConstructorParameters<typeof S3>[0]> = {};\n const s3Region = url.searchParams.get(\"region\");\n if (s3Region) s3Options.region = s3Region;\n const s3Bucket = url.hostname;\n const s3KeyPrefix = util.trimPrefix(url.pathname, \"/\");\n const s3Client = await newS3(s3Options, s3Bucket);\n return new S3Storage(s3Client, s3Bucket, s3KeyPrefix);\n }\n case \"s3e:\": {\n const s3eOptions: NonNullable<ConstructorParameters<typeof S3>[0]> = {};\n const s3eRegion = url.searchParams.get(\"region\");\n if (s3eRegion) s3eOptions.region = s3eRegion;\n\n const s3ePath = url.pathname.split(\"/\").slice(1); // '/bucket/keyPrefix' -> ['', 'bucket', 'keyPrefix'] -> ['bucket', 'keyPrefix']\n const s3eBucket = s3ePath[0];\n const s3eKeyPrefix = s3ePath.length > 1 ? util.trimPrefix(s3ePath[1], \"/\") : \"\";\n const s3eClient = await newS3(s3eOptions, s3eBucket);\n return new S3Storage(s3eClient, s3eBucket, s3eKeyPrefix);\n }\n default:\n throw util.CLIError(\n `Protocol ${url.protocol} is not supported for software registries yet. Use your own tooling for package upload`,\n );\n }\n } catch (e) {\n throw util.wrapErr(e, `failed to init storage driver from URL`);\n }\n}\n"],"mappings":";;;;;;AAyBA,eAAe,aAAa,QAAY,QAAgB,KAA+B;CACrF,IAAI;EACF,MAAM,OAAO,WAAW;GACtB,QAAQ;GACR,KAAK;EACP,CAAC;EAED,OAAO;CACT,SAAS,OAAO;EACd,IAAI,iBAAiB,SAAS,MAAM,SAAS,YAC3C,OAAO;EAGT,MAAMA,QAAa,OAAO,iDAAiD,QAAQ;CACrF;AACF;AAEA,eAAe,MACb,SACA,QACa;CACb,MAAM,SAAS,IAAI,GAAG,OAAO;CAE7B,IAAI;EACF,MAAM,aAAa,QAAQ,QAAQ,GAAG;CACxC,SAAS,OAAO;EACd,MAAMC,SACJ,yEAAyE,OAAO,KAAK,OACvF;CACF;CAEA,OAAO;AACT;AAEA,IAAa,YAAb,MAAkD;CAE9B;CACA;CACA;CAHlB,YACE,QACA,QACA,OAA+B,IAC/B;EAHgB,KAAA,SAAA;EACA,KAAA,SAAA;EACA,KAAA,OAAA;CACf;CAEH,MAAM,OAAO,MAAgC;EAC3C,OAAO,aAAa,KAAK,QAAQ,KAAK,QAAQ,UAAU,KAAK,KAAK,MAAM,IAAI,CAAC;CAC/E;CAEA,MAAM,QAAQ,MAAc,MAAwC;EAClE,IAAI;GAUF,MAAM,IATa,OAAO;IACxB,QAAQ,KAAK;IACb,QAAQ;KACN,QAAQ,KAAK;KACb,KAAK,UAAU,KAAK,KAAK,MAAM,IAAI;KACnC,MAAM;IACR;GACF,CAEW,CAAC,CAAC,KAAK;EACpB,SAAS,GAAG;GACV,MAAMD,QAAa,GAAG,uCAAuC,KAAK,QAAQ;EAC5E;CACF;AACF;AAEA,eAAsB,UAAU,SAAiB,SAA2C;CAC1F,IAAI,YAAY,IACd,MAAMC,SAAc,gCAAgC;CAGtD,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,SAAS,QAAQ,QAAQ,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,UAAU,GAAG,EAAE,EAAE;EACnF,QAAQ,IAAI,UAAZ;GACE,KAAK,OAAO;IACV,MAAM,YAA8D,CAAC;IACrE,MAAM,WAAW,IAAI,aAAa,IAAI,QAAQ;IAC9C,IAAI,UAAU,UAAU,SAAS;IACjC,MAAM,WAAW,IAAI;IACrB,MAAM,cAAcC,WAAgB,IAAI,UAAU,GAAG;IAErD,OAAO,IAAI,UAAU,MADE,MAAM,WAAW,QAAQ,GACjB,UAAU,WAAW;GACtD;GACA,KAAK,QAAQ;IACX,MAAM,aAA+D,CAAC;IACtE,MAAM,YAAY,IAAI,aAAa,IAAI,QAAQ;IAC/C,IAAI,WAAW,WAAW,SAAS;IAEnC,MAAM,UAAU,IAAI,SAAS,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,MAAM,YAAY,QAAQ;IAC1B,MAAM,eAAe,QAAQ,SAAS,IAAIA,WAAgB,QAAQ,IAAI,GAAG,IAAI;IAE7E,OAAO,IAAI,UAAU,MADG,MAAM,YAAY,SAAS,GACnB,WAAW,YAAY;GACzD;GACA,SACE,MAAMD,SACJ,YAAY,IAAI,SAAS,uFAC3B;EACJ;CACF,SAAS,GAAG;EACV,MAAMD,QAAa,GAAG,wCAAwC;CAChE;AACF"}
|
|
@@ -5,11 +5,13 @@ const require_artifacts = require("./schemas/artifacts.cjs");
|
|
|
5
5
|
const require_docker = require("./docker.cjs");
|
|
6
6
|
const require_resolver = require("./resolver.cjs");
|
|
7
7
|
let node_fs = require("node:fs");
|
|
8
|
-
node_fs = require_runtime.__toESM(node_fs);
|
|
8
|
+
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
9
9
|
let node_path = require("node:path");
|
|
10
|
-
node_path = require_runtime.__toESM(node_path);
|
|
10
|
+
node_path = require_runtime.__toESM(node_path, 1);
|
|
11
11
|
//#region src/core/sw-json-render.ts
|
|
12
12
|
var SwJsonRenderer = class {
|
|
13
|
+
logger;
|
|
14
|
+
pkgInfo;
|
|
13
15
|
constructor(logger, pkgInfo) {
|
|
14
16
|
this.logger = logger;
|
|
15
17
|
this.pkgInfo = pkgInfo;
|
|
@@ -32,9 +34,9 @@ var SwJsonRenderer = class {
|
|
|
32
34
|
name: originEpName
|
|
33
35
|
} };
|
|
34
36
|
if (!info) throw require_util.CLIError(`Entrypoint ${epName} not found in result`);
|
|
35
|
-
if (mode
|
|
37
|
+
if (require_util.isDevMode(mode)) info.isDev = true;
|
|
36
38
|
const pkg = ep.artifact;
|
|
37
|
-
if (require_util.
|
|
39
|
+
if (!require_util.producesRegistryDescriptor(mode)) {
|
|
38
40
|
switch (pkg.type) {
|
|
39
41
|
case "docker":
|
|
40
42
|
info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);
|
|
@@ -84,6 +86,28 @@ var SwJsonRenderer = class {
|
|
|
84
86
|
}
|
|
85
87
|
return result;
|
|
86
88
|
}
|
|
89
|
+
renderPlaceholderEntrypoints(entrypoints) {
|
|
90
|
+
const result = /* @__PURE__ */ new Map();
|
|
91
|
+
for (const [epName, ep] of entrypoints.entries()) {
|
|
92
|
+
if (ep.type === "reference") continue;
|
|
93
|
+
const originEpName = require_docker.entrypointNameToOrigin(epName);
|
|
94
|
+
if (result.has(originEpName)) continue;
|
|
95
|
+
result.set(originEpName, {
|
|
96
|
+
id: {
|
|
97
|
+
package: this.pkgInfo.packageName,
|
|
98
|
+
name: originEpName
|
|
99
|
+
},
|
|
100
|
+
isDev: true,
|
|
101
|
+
binary: {
|
|
102
|
+
type: "binary",
|
|
103
|
+
registry: require_defaults.NO_SOFTWARE_PLACEHOLDER,
|
|
104
|
+
package: require_defaults.NO_SOFTWARE_PLACEHOLDER,
|
|
105
|
+
cmd: ["true"]
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
87
111
|
writeSwJson(info, dstFile) {
|
|
88
112
|
const epType = info.asset ? "asset" : "software";
|
|
89
113
|
const dstSwInfoPath = dstFile ?? require_resolver.descriptorFilePath(this.pkgInfo.packageRoot, epType, info.id.name);
|
|
@@ -180,7 +204,8 @@ var SwJsonRenderer = class {
|
|
|
180
204
|
}
|
|
181
205
|
renderBinaryInfo(mode, epName, ep, requireArtifactInfo) {
|
|
182
206
|
switch (mode) {
|
|
183
|
-
case "release":
|
|
207
|
+
case "release":
|
|
208
|
+
case "dev-remote": break;
|
|
184
209
|
case "dev-local": throw new Error(`'*.sw.json' generator logic error`);
|
|
185
210
|
default: require_util.assertNever(mode);
|
|
186
211
|
}
|
|
@@ -248,7 +273,8 @@ var SwJsonRenderer = class {
|
|
|
248
273
|
}
|
|
249
274
|
renderRunEnvInfo(mode, epName, ep, requireArtifactInfo) {
|
|
250
275
|
switch (mode) {
|
|
251
|
-
case "release":
|
|
276
|
+
case "release":
|
|
277
|
+
case "dev-remote": break;
|
|
252
278
|
case "dev-local": throw require_util.CLIError(`run environments do not support 'local' dev build mode yet`);
|
|
253
279
|
default: require_util.assertNever(mode);
|
|
254
280
|
}
|
|
@@ -269,7 +295,8 @@ var SwJsonRenderer = class {
|
|
|
269
295
|
}
|
|
270
296
|
renderAssetInfo(mode, epName, ep, requireArtifactInfo) {
|
|
271
297
|
switch (mode) {
|
|
272
|
-
case "release":
|
|
298
|
+
case "release":
|
|
299
|
+
case "dev-remote": break;
|
|
273
300
|
case "dev-local": throw require_util.CLIError(`assets do not support 'local' dev build mode yet`);
|
|
274
301
|
default: require_util.assertNever(mode);
|
|
275
302
|
}
|
|
@@ -298,6 +325,8 @@ var SwJsonRenderer = class {
|
|
|
298
325
|
};
|
|
299
326
|
}
|
|
300
327
|
};
|
|
328
|
+
const compiledSoftwareSuffix = ".sw.json";
|
|
329
|
+
const compiledAssetSuffix = ".as.json";
|
|
301
330
|
function writeBuiltArtifactInfo(location, locInfo) {
|
|
302
331
|
node_fs.default.mkdirSync(node_path.default.dirname(location), { recursive: true });
|
|
303
332
|
node_fs.default.writeFileSync(location, JSON.stringify(locInfo), { encoding: "utf8" });
|
|
@@ -321,6 +350,8 @@ function requireArtifactType(pkg, type, errMsg) {
|
|
|
321
350
|
}
|
|
322
351
|
//#endregion
|
|
323
352
|
exports.SwJsonRenderer = SwJsonRenderer;
|
|
353
|
+
exports.compiledAssetSuffix = compiledAssetSuffix;
|
|
354
|
+
exports.compiledSoftwareSuffix = compiledSoftwareSuffix;
|
|
324
355
|
exports.readBuiltArtifactInfo = readBuiltArtifactInfo;
|
|
325
356
|
exports.writeBuiltArtifactInfo = writeBuiltArtifactInfo;
|
|
326
357
|
|