@uns-kit/core 3.0.6 → 3.0.9

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.
Files changed (57) hide show
  1. package/MIGRATIONS.md +57 -3
  2. package/dist/config/project.config.extension.d.ts +1 -1
  3. package/dist/config/project.config.extension.d.ts.map +1 -1
  4. package/dist/examples/datahub-client.js +6 -7
  5. package/dist/examples/datahub-client.js.map +1 -1
  6. package/dist/index.d.ts +4 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +2 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/logger.d.ts.map +1 -1
  11. package/dist/logger.js +29 -30
  12. package/dist/logger.js.map +1 -1
  13. package/dist/tools/auth/auth-client.d.ts +2 -0
  14. package/dist/tools/auth/auth-client.d.ts.map +1 -1
  15. package/dist/tools/auth/auth-client.js +9 -7
  16. package/dist/tools/auth/auth-client.js.map +1 -1
  17. package/dist/tools/auth/index.d.ts +2 -0
  18. package/dist/tools/auth/index.d.ts.map +1 -1
  19. package/dist/tools/auth/index.js +1 -0
  20. package/dist/tools/auth/index.js.map +1 -1
  21. package/dist/tools/auth/service-token-provider.d.ts +44 -0
  22. package/dist/tools/auth/service-token-provider.d.ts.map +1 -0
  23. package/dist/tools/auth/service-token-provider.js +54 -0
  24. package/dist/tools/auth/service-token-provider.js.map +1 -0
  25. package/dist/tools/datahub/datahub-client.d.ts +4 -0
  26. package/dist/tools/datahub/datahub-client.d.ts.map +1 -1
  27. package/dist/tools/datahub/datahub-client.js +5 -0
  28. package/dist/tools/datahub/datahub-client.js.map +1 -1
  29. package/dist/tools/generate-config-schema.js +67 -11
  30. package/dist/tools/generate-config-schema.js.map +1 -1
  31. package/dist/uns/uns-attributes.d.ts +2 -2
  32. package/dist/uns/uns-interfaces.d.ts +5 -1
  33. package/dist/uns/uns-interfaces.d.ts.map +1 -1
  34. package/dist/uns/uns-interfaces.js.map +1 -1
  35. package/dist/uns-config/config-schema.d.ts +405 -5
  36. package/dist/uns-config/config-schema.d.ts.map +1 -1
  37. package/dist/uns-config/host-placeholders.d.ts +14 -98
  38. package/dist/uns-config/host-placeholders.d.ts.map +1 -1
  39. package/dist/uns-config/mqtt-channel.d.ts +18 -0
  40. package/dist/uns-config/mqtt-channel.d.ts.map +1 -0
  41. package/dist/uns-config/mqtt-channel.js +75 -0
  42. package/dist/uns-config/mqtt-channel.js.map +1 -0
  43. package/dist/uns-config/schema-tolls.d.ts +1 -2
  44. package/dist/uns-config/schema-tolls.d.ts.map +1 -1
  45. package/dist/uns-config/schema-tolls.js +2 -4
  46. package/dist/uns-config/schema-tolls.js.map +1 -1
  47. package/dist/uns-config/schema-tools.d.ts +6 -1
  48. package/dist/uns-config/schema-tools.d.ts.map +1 -1
  49. package/dist/uns-config/schema-tools.js +7 -8
  50. package/dist/uns-config/schema-tools.js.map +1 -1
  51. package/dist/uns-config/secret-placeholders.d.ts +8 -86
  52. package/dist/uns-config/secret-placeholders.d.ts.map +1 -1
  53. package/dist/uns-config/uns-core-schema.d.ts +191 -3106
  54. package/dist/uns-config/uns-core-schema.d.ts.map +1 -1
  55. package/dist/uns-config/uns-core-schema.js +61 -68
  56. package/dist/uns-config/uns-core-schema.js.map +1 -1
  57. package/package.json +3 -4
@@ -0,0 +1,75 @@
1
+ const CHANNEL_FIELDS = [
2
+ "host",
3
+ "hosts",
4
+ "servers",
5
+ "port",
6
+ "protocol",
7
+ "username",
8
+ "password",
9
+ "clientId",
10
+ "clean",
11
+ "keepalive",
12
+ "connectTimeout",
13
+ "reconnectPeriod",
14
+ "reconnectOnConnackError",
15
+ "resubscribe",
16
+ "queueQoSZero",
17
+ "rejectUnauthorized",
18
+ "ca",
19
+ "cert",
20
+ "key",
21
+ "servername",
22
+ ];
23
+ /**
24
+ * Resolves `input` or `output` as an overlay on the full `infra` MQTT
25
+ * connection. This preserves credentials, TLS, reconnect behaviour, and
26
+ * multi-host configuration when a service only needs to override one field.
27
+ */
28
+ export function resolveMqttChannel(infra, override) {
29
+ const resolved = {};
30
+ for (const field of CHANNEL_FIELDS) {
31
+ const value = override?.[field] ?? infra[field];
32
+ if (value !== undefined) {
33
+ setChannelField(resolved, field, cloneChannelValue(value));
34
+ }
35
+ }
36
+ const infraProperties = infra.properties;
37
+ const overrideProperties = override?.properties;
38
+ if (infraProperties || overrideProperties) {
39
+ resolved.properties = {
40
+ ...(infraProperties ?? {}),
41
+ ...(overrideProperties ?? {}),
42
+ ...(infraProperties?.userProperties || overrideProperties?.userProperties
43
+ ? {
44
+ userProperties: {
45
+ ...(infraProperties?.userProperties ?? {}),
46
+ ...(overrideProperties?.userProperties ?? {}),
47
+ },
48
+ }
49
+ : {}),
50
+ };
51
+ }
52
+ const host = firstNonEmptyString(resolved.host, resolved.hosts?.[0], resolved.servers?.[0]?.host);
53
+ if (!host) {
54
+ throw new Error("MQTT channel requires infra.host, infra.hosts, infra.servers, or an explicit channel host.");
55
+ }
56
+ return { ...resolved, host };
57
+ }
58
+ /** Returns the connection options accepted by UnsProxyProcess/UnsMqttProxy. */
59
+ export function mqttChannelParameters(channel) {
60
+ const { host: _host, ...parameters } = channel;
61
+ return parameters;
62
+ }
63
+ function setChannelField(target, field, value) {
64
+ target[field] = value;
65
+ }
66
+ function cloneChannelValue(value) {
67
+ if (Array.isArray(value)) {
68
+ return value.map((entry) => entry && typeof entry === "object" ? { ...entry } : entry);
69
+ }
70
+ return value;
71
+ }
72
+ function firstNonEmptyString(...values) {
73
+ return values.find((value) => typeof value === "string" && value.trim().length > 0)?.trim();
74
+ }
75
+ //# sourceMappingURL=mqtt-channel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mqtt-channel.js","sourceRoot":"","sources":["../../src/uns-config/mqtt-channel.ts"],"names":[],"mappings":"AAsCA,MAAM,cAAc,GAAmC;IACrD,MAAM;IACN,OAAO;IACP,SAAS;IACT,MAAM;IACN,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,OAAO;IACP,WAAW;IACX,gBAAg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AC5B,CAAC;IACF,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAC;IAChH,CAAC;IACD,OAAO,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC/B,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,qBAAqB,CAAC,OAA4B;IAChE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/C,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,eAAe,CACtB,MAAyB,EACzB,KAA8B,EAC9B,KAAc;IAEb,MAAkC,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;AACrD,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACzB,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAI,KAAiC,EAAE,CAAC,CAAC,CAAC,KAAK,CACvF,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAG,MAAiC;IAC/D,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;AAC9F,CAAC","sourcesContent":["import type {\n IMqttConnectProperties,\n IMqttParameters,\n IMqttServerConfig,\n MqttProtocol,\n} from \"../uns-mqtt/mqtt-interfaces.js\";\n\n/** A config-file MQTT channel before its optional override is merged with infra. */\nexport type MqttChannelConfig = Pick<\n IMqttParameters,\n | \"username\"\n | \"password\"\n | \"clientId\"\n | \"hosts\"\n | \"servers\"\n | \"port\"\n | \"protocol\"\n | \"keepalive\"\n | \"clean\"\n | \"connectTimeout\"\n | \"reconnectPeriod\"\n | \"reconnectOnConnackError\"\n | \"resubscribe\"\n | \"queueQoSZero\"\n | \"rejectUnauthorized\"\n | \"properties\"\n | \"ca\"\n | \"cert\"\n | \"key\"\n | \"servername\"\n> & {\n host?: string;\n};\n\nexport type ResolvedMqttChannel = MqttChannelConfig & {\n host: string;\n};\n\nconst CHANNEL_FIELDS: Array<keyof MqttChannelConfig> = [\n \"host\",\n \"hosts\",\n \"servers\",\n \"port\",\n \"protocol\",\n \"username\",\n \"password\",\n \"clientId\",\n \"clean\",\n \"keepalive\",\n \"connectTimeout\",\n \"reconnectPeriod\",\n \"reconnectOnConnackError\",\n \"resubscribe\",\n \"queueQoSZero\",\n \"rejectUnauthorized\",\n \"ca\",\n \"cert\",\n \"key\",\n \"servername\",\n];\n\n/**\n * Resolves `input` or `output` as an overlay on the full `infra` MQTT\n * connection. This preserves credentials, TLS, reconnect behaviour, and\n * multi-host configuration when a service only needs to override one field.\n */\nexport function resolveMqttChannel(\n infra: MqttChannelConfig,\n override?: MqttChannelConfig,\n): ResolvedMqttChannel {\n const resolved: MqttChannelConfig = {};\n for (const field of CHANNEL_FIELDS) {\n const value = override?.[field] ?? infra[field];\n if (value !== undefined) {\n setChannelField(resolved, field, cloneChannelValue(value));\n }\n }\n\n const infraProperties = infra.properties;\n const overrideProperties = override?.properties;\n if (infraProperties || overrideProperties) {\n resolved.properties = {\n ...(infraProperties ?? {}),\n ...(overrideProperties ?? {}),\n ...(infraProperties?.userProperties || overrideProperties?.userProperties\n ? {\n userProperties: {\n ...(infraProperties?.userProperties ?? {}),\n ...(overrideProperties?.userProperties ?? {}),\n },\n }\n : {}),\n };\n }\n\n const host = firstNonEmptyString(\n resolved.host,\n resolved.hosts?.[0],\n resolved.servers?.[0]?.host,\n );\n if (!host) {\n throw new Error(\"MQTT channel requires infra.host, infra.hosts, infra.servers, or an explicit channel host.\");\n }\n return { ...resolved, host };\n}\n\n/** Returns the connection options accepted by UnsProxyProcess/UnsMqttProxy. */\nexport function mqttChannelParameters(channel: ResolvedMqttChannel): IMqttParameters {\n const { host: _host, ...parameters } = channel;\n return parameters;\n}\n\nfunction setChannelField(\n target: MqttChannelConfig,\n field: keyof MqttChannelConfig,\n value: unknown,\n): void {\n (target as Record<string, unknown>)[field] = value;\n}\n\nfunction cloneChannelValue(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map((entry) =>\n entry && typeof entry === \"object\" ? { ...(entry as Record<string, unknown>) } : entry,\n );\n }\n return value;\n}\n\nfunction firstNonEmptyString(...values: Array<string | undefined>): string | undefined {\n return values.find((value) => typeof value === \"string\" && value.trim().length > 0)?.trim();\n}\n\nexport type { IMqttConnectProperties, IMqttServerConfig, MqttProtocol };\n"]}
@@ -1,3 +1,2 @@
1
- import { z } from "zod";
2
- export declare function composeConfigSchema<A extends z.AnyZodObject, B extends z.AnyZodObject>(a: A, b: B): z.ZodObject<A["shape"] & B["shape"]>;
1
+ export { composeConfigSchema } from "./schema-tools.js";
3
2
  //# sourceMappingURL=schema-tolls.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-tolls.d.ts","sourceRoot":"","sources":["../../src/uns-config/schema-tolls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,wBAAgB,mBAAmB,CACjC,CAAC,SAAS,CAAC,CAAC,YAAY,EACxB,CAAC,SAAS,CAAC,CAAC,YAAY,EACxB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAElD"}
1
+ {"version":3,"file":"schema-tolls.d.ts","sourceRoot":"","sources":["../../src/uns-config/schema-tolls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,5 +1,3 @@
1
- // Shallow merge of two ZodObjects into one ZodObject
2
- export function composeConfigSchema(a, b) {
3
- return a.merge(b);
4
- }
1
+ // Backwards-compatible export for the historical misspelled module path.
2
+ export { composeConfigSchema } from "./schema-tools.js";
5
3
  //# sourceMappingURL=schema-tolls.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-tolls.js","sourceRoot":"","sources":["../../src/uns-config/schema-tolls.ts"],"names":[],"mappings":"AAEA,qDAAqD;AACrD,MAAM,UAAU,mBAAmB,CAGjC,CAAI,EAAE,CAAI;IACV,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAQ,CAAC;AAC3B,CAAC","sourcesContent":["import { z } from \"zod\";\n\n// Shallow merge of two ZodObjects into one ZodObject\nexport function composeConfigSchema<\n A extends z.AnyZodObject,\n B extends z.AnyZodObject\n>(a: A, b: B): z.ZodObject<A[\"shape\"] & B[\"shape\"]> {\n return a.merge(b) as any;\n}\n"]}
1
+ {"version":3,"file":"schema-tolls.js","sourceRoot":"","sources":["../../src/uns-config/schema-tolls.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["// Backwards-compatible export for the historical misspelled module path.\nexport { composeConfigSchema } from \"./schema-tools.js\";\n"]}
@@ -1,3 +1,8 @@
1
1
  import { z } from "zod";
2
- export declare function composeConfigSchema(core: z.AnyZodObject, ...extras: z.AnyZodObject[]): z.AnyZodObject;
2
+ export type ConfigObjectSchema = z.ZodObject<z.ZodRawShape>;
3
+ type SchemaShape<TSchema extends ConfigObjectSchema> = TSchema extends z.ZodObject<infer TShape> ? TShape : never;
4
+ type MergedExtraShapes<TSchemas extends readonly ConfigObjectSchema[], TShape extends z.ZodRawShape = Record<never, never>> = TSchemas extends readonly [infer THead extends ConfigObjectSchema, ...infer TTail extends readonly ConfigObjectSchema[]] ? MergedExtraShapes<TTail, TShape & SchemaShape<THead>> : TShape;
5
+ export declare function composeConfigSchema(core: ConfigObjectSchema): ConfigObjectSchema;
6
+ export declare function composeConfigSchema<TCore extends ConfigObjectSchema, TExtras extends readonly ConfigObjectSchema[]>(core: TCore, ...extras: TExtras): z.ZodObject<SchemaShape<TCore> & MergedExtraShapes<TExtras>>;
7
+ export {};
3
8
  //# sourceMappingURL=schema-tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-tools.d.ts","sourceRoot":"","sources":["../../src/uns-config/schema-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,CAAC,CAAC,YAAY,EACpB,GAAG,MAAM,EAAE,CAAC,CAAC,YAAY,EAAE,GAC1B,CAAC,CAAC,YAAY,CAWhB"}
1
+ {"version":3,"file":"schema-tools.d.ts","sourceRoot":"","sources":["../../src/uns-config/schema-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;AAE5D,KAAK,WAAW,CAAC,OAAO,SAAS,kBAAkB,IAAI,OAAO,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC;AAElH,KAAK,iBAAiB,CACpB,QAAQ,SAAS,SAAS,kBAAkB,EAAE,EAC9C,MAAM,SAAS,CAAC,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IACjD,QAAQ,SAAS,SAAS,CAAC,MAAM,KAAK,SAAS,kBAAkB,EAAE,GAAG,MAAM,KAAK,SAAS,SAAS,kBAAkB,EAAE,CAAC,GACxH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,GACrD,MAAM,CAAC;AAMX,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,GAAG,kBAAkB,CAAC;AAClF,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,kBAAkB,EAAE,OAAO,SAAS,SAAS,kBAAkB,EAAE,EACjH,IAAI,EAAE,KAAK,EACX,GAAG,MAAM,EAAE,OAAO,GACjB,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC"}
@@ -1,19 +1,18 @@
1
- // Helper functions in camelCase
2
- function shapeKeys(obj) {
3
- const shape = obj?._def?.shape();
4
- return Object.keys(shape ?? {});
1
+ function shapeKeys(schema) {
2
+ return Object.keys(schema.shape);
5
3
  }
6
- // Function in camelCase is fine
7
4
  export function composeConfigSchema(core, ...extras) {
8
5
  const coreKeys = new Set(shapeKeys(core));
6
+ let composed = core;
9
7
  for (const ext of extras) {
10
8
  const keys = shapeKeys(ext);
11
- const overlaps = keys.filter(k => coreKeys.has(k));
9
+ const overlaps = keys.filter((k) => coreKeys.has(k));
12
10
  if (overlaps.length) {
13
11
  throw new Error(`Project extras overlap UNS core keys: ${overlaps.join(", ")}`);
14
12
  }
15
- keys.forEach(k => coreKeys.add(k));
13
+ keys.forEach((k) => coreKeys.add(k));
14
+ composed = composed.extend(ext.shape);
16
15
  }
17
- return extras.reduce((acc, ext) => acc.merge(ext), core);
16
+ return composed;
18
17
  }
19
18
  //# sourceMappingURL=schema-tools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-tools.js","sourceRoot":"","sources":["../../src/uns-config/schema-tools.ts"],"names":[],"mappings":"AAEA,gCAAgC;AAChC,SAAS,SAAS,CAAC,GAAmB;IACpC,MAAM,KAAK,GAAI,GAAW,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAC1C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,gCAAgC;AAChC,MAAM,UAAU,mBAAmB,CACjC,IAAoB,EACpB,GAAG,MAAwB;IAE3B,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,yCAAyC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClF,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import { z } from \"zod\";\n\n// Helper functions in camelCase\nfunction shapeKeys(obj: z.AnyZodObject) {\n const shape = (obj as any)?._def?.shape();\n return Object.keys(shape ?? {});\n}\n\n// Function in camelCase is fine\nexport function composeConfigSchema(\n core: z.AnyZodObject,\n ...extras: z.AnyZodObject[]\n): z.AnyZodObject {\n const coreKeys = new Set(shapeKeys(core));\n for (const ext of extras) {\n const keys = shapeKeys(ext);\n const overlaps = keys.filter(k => coreKeys.has(k));\n if (overlaps.length) {\n throw new Error(`Project extras overlap UNS core keys: ${overlaps.join(\", \")}`);\n }\n keys.forEach(k => coreKeys.add(k));\n }\n return extras.reduce((acc, ext) => acc.merge(ext), core);\n}\n"]}
1
+ {"version":3,"file":"schema-tools.js","sourceRoot":"","sources":["../../src/uns-config/schema-tools.ts"],"names":[],"mappings":"AAaA,SAAS,SAAS,CAAC,MAA0B;IAC3C,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAOD,MAAM,UAAU,mBAAmB,CAAC,IAAwB,EAAE,GAAG,MAA4B;IAC3F,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,IAAI,QAAQ,GAAG,IAAI,CAAC;IAEpB,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,yCAAyC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClF,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { z } from \"zod\";\n\nexport type ConfigObjectSchema = z.ZodObject<z.ZodRawShape>;\n\ntype SchemaShape<TSchema extends ConfigObjectSchema> = TSchema extends z.ZodObject<infer TShape> ? TShape : never;\n\ntype MergedExtraShapes<\n TSchemas extends readonly ConfigObjectSchema[],\n TShape extends z.ZodRawShape = Record<never, never>,\n> = TSchemas extends readonly [infer THead extends ConfigObjectSchema, ...infer TTail extends readonly ConfigObjectSchema[]]\n ? MergedExtraShapes<TTail, TShape & SchemaShape<THead>>\n : TShape;\n\nfunction shapeKeys(schema: ConfigObjectSchema): string[] {\n return Object.keys(schema.shape);\n}\n\nexport function composeConfigSchema(core: ConfigObjectSchema): ConfigObjectSchema;\nexport function composeConfigSchema<TCore extends ConfigObjectSchema, TExtras extends readonly ConfigObjectSchema[]>(\n core: TCore,\n ...extras: TExtras\n): z.ZodObject<SchemaShape<TCore> & MergedExtraShapes<TExtras>>;\nexport function composeConfigSchema(core: ConfigObjectSchema, ...extras: ConfigObjectSchema[]): ConfigObjectSchema {\n const coreKeys = new Set(shapeKeys(core));\n let composed = core;\n\n for (const ext of extras) {\n const keys = shapeKeys(ext);\n const overlaps = keys.filter((k) => coreKeys.has(k));\n if (overlaps.length) {\n throw new Error(`Project extras overlap UNS core keys: ${overlaps.join(\", \")}`);\n }\n keys.forEach((k) => coreKeys.add(k));\n composed = composed.extend(ext.shape);\n }\n\n return composed;\n}\n"]}
@@ -4,17 +4,7 @@ declare const envSecretSchema: z.ZodObject<{
4
4
  key: z.ZodString;
5
5
  optional: z.ZodOptional<z.ZodBoolean>;
6
6
  default: z.ZodOptional<z.ZodString>;
7
- }, "strict", z.ZodTypeAny, {
8
- provider?: "env";
9
- key?: string;
10
- optional?: boolean;
11
- default?: string;
12
- }, {
13
- provider?: "env";
14
- key?: string;
15
- optional?: boolean;
16
- default?: string;
17
- }>;
7
+ }, z.core.$strict>;
18
8
  declare const infisicalSecretSchema: z.ZodObject<{
19
9
  provider: z.ZodLiteral<"infisical">;
20
10
  path: z.ZodString;
@@ -23,39 +13,13 @@ declare const infisicalSecretSchema: z.ZodObject<{
23
13
  environment: z.ZodOptional<z.ZodString>;
24
14
  projectId: z.ZodOptional<z.ZodString>;
25
15
  default: z.ZodOptional<z.ZodString>;
26
- }, "strict", z.ZodTypeAny, {
27
- provider?: "infisical";
28
- key?: string;
29
- optional?: boolean;
30
- default?: string;
31
- path?: string;
32
- environment?: string;
33
- projectId?: string;
34
- }, {
35
- provider?: "infisical";
36
- key?: string;
37
- optional?: boolean;
38
- default?: string;
39
- path?: string;
40
- environment?: string;
41
- projectId?: string;
42
- }>;
43
- export declare const secretPlaceholderSchema: z.ZodDiscriminatedUnion<"provider", [z.ZodObject<{
16
+ }, z.core.$strict>;
17
+ export declare const secretPlaceholderSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
44
18
  provider: z.ZodLiteral<"env">;
45
19
  key: z.ZodString;
46
20
  optional: z.ZodOptional<z.ZodBoolean>;
47
21
  default: z.ZodOptional<z.ZodString>;
48
- }, "strict", z.ZodTypeAny, {
49
- provider?: "env";
50
- key?: string;
51
- optional?: boolean;
52
- default?: string;
53
- }, {
54
- provider?: "env";
55
- key?: string;
56
- optional?: boolean;
57
- default?: string;
58
- }>, z.ZodObject<{
22
+ }, z.core.$strict>, z.ZodObject<{
59
23
  provider: z.ZodLiteral<"infisical">;
60
24
  path: z.ZodString;
61
25
  key: z.ZodString;
@@ -63,39 +27,13 @@ export declare const secretPlaceholderSchema: z.ZodDiscriminatedUnion<"provider"
63
27
  environment: z.ZodOptional<z.ZodString>;
64
28
  projectId: z.ZodOptional<z.ZodString>;
65
29
  default: z.ZodOptional<z.ZodString>;
66
- }, "strict", z.ZodTypeAny, {
67
- provider?: "infisical";
68
- key?: string;
69
- optional?: boolean;
70
- default?: string;
71
- path?: string;
72
- environment?: string;
73
- projectId?: string;
74
- }, {
75
- provider?: "infisical";
76
- key?: string;
77
- optional?: boolean;
78
- default?: string;
79
- path?: string;
80
- environment?: string;
81
- projectId?: string;
82
- }>]>;
83
- export declare const secretValueSchema: z.ZodUnion<[z.ZodString, z.ZodDiscriminatedUnion<"provider", [z.ZodObject<{
30
+ }, z.core.$strict>], "provider">;
31
+ export declare const secretValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
84
32
  provider: z.ZodLiteral<"env">;
85
33
  key: z.ZodString;
86
34
  optional: z.ZodOptional<z.ZodBoolean>;
87
35
  default: z.ZodOptional<z.ZodString>;
88
- }, "strict", z.ZodTypeAny, {
89
- provider?: "env";
90
- key?: string;
91
- optional?: boolean;
92
- default?: string;
93
- }, {
94
- provider?: "env";
95
- key?: string;
96
- optional?: boolean;
97
- default?: string;
98
- }>, z.ZodObject<{
36
+ }, z.core.$strict>, z.ZodObject<{
99
37
  provider: z.ZodLiteral<"infisical">;
100
38
  path: z.ZodString;
101
39
  key: z.ZodString;
@@ -103,23 +41,7 @@ export declare const secretValueSchema: z.ZodUnion<[z.ZodString, z.ZodDiscrimina
103
41
  environment: z.ZodOptional<z.ZodString>;
104
42
  projectId: z.ZodOptional<z.ZodString>;
105
43
  default: z.ZodOptional<z.ZodString>;
106
- }, "strict", z.ZodTypeAny, {
107
- provider?: "infisical";
108
- key?: string;
109
- optional?: boolean;
110
- default?: string;
111
- path?: string;
112
- environment?: string;
113
- projectId?: string;
114
- }, {
115
- provider?: "infisical";
116
- key?: string;
117
- optional?: boolean;
118
- default?: string;
119
- path?: string;
120
- environment?: string;
121
- projectId?: string;
122
- }>]>]>;
44
+ }, z.core.$strict>], "provider">]>;
123
45
  export type SecretPlaceholder = z.infer<typeof secretPlaceholderSchema>;
124
46
  export type SecretValue = z.infer<typeof secretValueSchema>;
125
47
  export type EnvSecretPlaceholder = z.infer<typeof envSecretSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"secret-placeholders.d.ts","sourceRoot":"","sources":["../../src/uns-config/secret-placeholders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;EAiBuC,CAAC;AAE7D,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;EA6B+B,CAAC;AAE3D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGlC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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