@tier0/sdk-v2 0.8.0 → 0.9.1

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 (106) hide show
  1. package/NOTICE.md +3 -1
  2. package/README.md +45 -11
  3. package/dist/cjs/capabilities.d.ts +8 -17
  4. package/dist/cjs/capabilities.js +17 -28
  5. package/dist/cjs/capabilities.js.map +1 -1
  6. package/dist/cjs/client.d.ts +524 -3
  7. package/dist/cjs/client.js +29 -6
  8. package/dist/cjs/client.js.map +1 -1
  9. package/dist/cjs/cloud-transport.d.ts +4 -2
  10. package/dist/cjs/cloud-transport.js +27 -18
  11. package/dist/cjs/cloud-transport.js.map +1 -1
  12. package/dist/cjs/files.d.ts +26 -6
  13. package/dist/cjs/files.js +151 -28
  14. package/dist/cjs/files.js.map +1 -1
  15. package/dist/cjs/index.d.ts +2 -1
  16. package/dist/cjs/index.js +3 -1
  17. package/dist/cjs/index.js.map +1 -1
  18. package/dist/cjs/openapi/api.generated.d.ts +1 -1
  19. package/dist/cjs/openapi/codecs.generated.d.ts +30 -161
  20. package/dist/cjs/openapi/codecs.generated.js +1 -1
  21. package/dist/cjs/openapi/codecs.generated.js.map +1 -1
  22. package/dist/cjs/openapi/types.generated.d.ts +33 -85
  23. package/dist/cjs/openapi/types.generated.js.map +1 -1
  24. package/dist/cjs/runtime.d.ts +13 -0
  25. package/dist/cjs/runtime.js +51 -0
  26. package/dist/cjs/runtime.js.map +1 -0
  27. package/dist/cjs/streams/capabilities.d.ts +8 -0
  28. package/dist/cjs/streams/capabilities.js +19 -0
  29. package/dist/cjs/streams/capabilities.js.map +1 -0
  30. package/dist/cjs/streams/contract.generated.d.ts +802 -0
  31. package/dist/cjs/streams/contract.generated.js +7 -0
  32. package/dist/cjs/streams/contract.generated.js.map +1 -0
  33. package/dist/cjs/streams/index.d.ts +3 -0
  34. package/dist/cjs/streams/index.js +20 -0
  35. package/dist/cjs/streams/index.js.map +1 -0
  36. package/dist/cjs/streams/messages.d.ts +42 -0
  37. package/dist/cjs/streams/messages.js +514 -0
  38. package/dist/cjs/streams/messages.js.map +1 -0
  39. package/dist/cjs/streams/requests.d.ts +93 -0
  40. package/dist/cjs/streams/requests.js +167 -0
  41. package/dist/cjs/streams/requests.js.map +1 -0
  42. package/dist/cjs/streams/transport.d.ts +16 -0
  43. package/dist/cjs/streams/transport.js +24 -0
  44. package/dist/cjs/streams/transport.js.map +1 -0
  45. package/dist/cjs/uns-v2/generated.d.ts +87 -22
  46. package/dist/cjs/uns-v2/generated.js +43 -8
  47. package/dist/cjs/uns-v2/generated.js.map +1 -1
  48. package/dist/esm/capabilities.d.ts +8 -17
  49. package/dist/esm/capabilities.js +17 -28
  50. package/dist/esm/capabilities.js.map +1 -1
  51. package/dist/esm/client.d.ts +524 -3
  52. package/dist/esm/client.js +27 -5
  53. package/dist/esm/client.js.map +1 -1
  54. package/dist/esm/cloud-transport.d.ts +4 -2
  55. package/dist/esm/cloud-transport.js +27 -18
  56. package/dist/esm/cloud-transport.js.map +1 -1
  57. package/dist/esm/files.d.ts +26 -6
  58. package/dist/esm/files.js +151 -28
  59. package/dist/esm/files.js.map +1 -1
  60. package/dist/esm/index.d.ts +2 -1
  61. package/dist/esm/index.js +2 -1
  62. package/dist/esm/index.js.map +1 -1
  63. package/dist/esm/openapi/api.generated.d.ts +1 -1
  64. package/dist/esm/openapi/codecs.generated.d.ts +30 -161
  65. package/dist/esm/openapi/codecs.generated.js +1 -1
  66. package/dist/esm/openapi/codecs.generated.js.map +1 -1
  67. package/dist/esm/openapi/types.generated.d.ts +33 -85
  68. package/dist/esm/openapi/types.generated.js.map +1 -1
  69. package/dist/esm/runtime.d.ts +13 -0
  70. package/dist/esm/runtime.js +46 -0
  71. package/dist/esm/runtime.js.map +1 -0
  72. package/dist/esm/streams/capabilities.d.ts +8 -0
  73. package/dist/esm/streams/capabilities.js +15 -0
  74. package/dist/esm/streams/capabilities.js.map +1 -0
  75. package/dist/esm/streams/contract.generated.d.ts +802 -0
  76. package/dist/esm/streams/contract.generated.js +6 -0
  77. package/dist/esm/streams/contract.generated.js.map +1 -0
  78. package/dist/esm/streams/index.d.ts +3 -0
  79. package/dist/esm/streams/index.js +4 -0
  80. package/dist/esm/streams/index.js.map +1 -0
  81. package/dist/esm/streams/messages.d.ts +42 -0
  82. package/dist/esm/streams/messages.js +475 -0
  83. package/dist/esm/streams/messages.js.map +1 -0
  84. package/dist/esm/streams/requests.d.ts +93 -0
  85. package/dist/esm/streams/requests.js +161 -0
  86. package/dist/esm/streams/requests.js.map +1 -0
  87. package/dist/esm/streams/transport.d.ts +16 -0
  88. package/dist/esm/streams/transport.js +20 -0
  89. package/dist/esm/streams/transport.js.map +1 -0
  90. package/dist/esm/uns-v2/generated.d.ts +87 -22
  91. package/dist/esm/uns-v2/generated.js +43 -8
  92. package/dist/esm/uns-v2/generated.js.map +1 -1
  93. package/package.json +46 -12
  94. package/skills/tier0-sdk-v2/SKILL.md +3 -2
  95. package/skills/tier0-sdk-v2/tier0-sdk-v2-files/references/multipart.md +23 -8
  96. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/SKILL.md +3 -3
  97. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/create.md +9 -3
  98. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/state.md +1 -1
  99. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/update.md +1 -1
  100. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/SKILL.md +2 -1
  101. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/create.md +13 -4
  102. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/deploy.md +1 -1
  103. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/update.md +1 -1
  104. package/skills/tier0-sdk-v2/tier0-sdk-v2-streams/SKILL.md +67 -0
  105. package/skills/tier0-sdk-v2/tier0-sdk-v2-system/SKILL.md +5 -9
  106. package/skills/tier0-sdk-v2/tier0-sdk-v2-system/references/info.md +1 -1
@@ -0,0 +1,93 @@
1
+ import { StreamTransport, type StreamTransportConfig } from './transport.js';
2
+ import type { components } from './contract.generated.js';
3
+ /** Public request contracts do not expose runtime bindings. */
4
+ export type StreamJSON = null | boolean | number | string | StreamJSON[] | {
5
+ [key: string]: StreamJSON;
6
+ };
7
+ export interface PublicStreamRequest extends Omit<components['schemas']['PublicStreamRequest'], 'inputSchema' | 'outputSchema' | 'sideEffect' | 'idempotency'> {
8
+ code: string;
9
+ name: string;
10
+ description: string;
11
+ contractVersion: string;
12
+ inputSchema: Record<string, StreamJSON>;
13
+ outputSchema: Record<string, StreamJSON>;
14
+ sideEffect: 'read' | 'write';
15
+ idempotency: 'none' | 'optional' | 'required';
16
+ timeoutMs: number;
17
+ status: string;
18
+ }
19
+ type WireDiscovery = components['schemas']['StreamRequestDiscoverReq'];
20
+ export interface StreamRequestDiscoverOptions extends WireDiscovery {
21
+ page?: number;
22
+ size?: number;
23
+ search?: string;
24
+ }
25
+ export interface StreamRequestDiscoverResponse {
26
+ total: number;
27
+ list: PublicStreamRequest[];
28
+ }
29
+ /** HTTP transport settings do not override server execution semantics. */
30
+ export interface StreamRequestTransportConfig extends StreamTransportConfig {
31
+ }
32
+ export declare const DEFAULT_STREAM_REQUEST_TRANSPORT_TIMEOUT_MS = 60000;
33
+ export interface StreamRequestInvokeOptions {
34
+ /** Stable caller-owned key for one business intent, at most 128 UTF-8 bytes. Never generated or retried by the SDK. */
35
+ idempotencyKey?: string;
36
+ }
37
+ export interface StreamRequestInvokeResponse<Result = StreamJSON> extends Omit<components['schemas']['StreamRequestInvokeResp'], 'result' | 'status'> {
38
+ code: string;
39
+ contractVersion: string;
40
+ result: Result;
41
+ runID: string;
42
+ /** Persisted request ledger success; all other states reject conservatively. */
43
+ status: 'completed';
44
+ /** True only when the server explicitly reports an idempotent replay. */
45
+ replayed: boolean;
46
+ }
47
+ export interface StreamRequestErrorInfo {
48
+ /** HTTP status, absent when no HTTP response was received. */
49
+ status?: number;
50
+ /** Gateway string errorCode, or an SDK-local STREAM_REQUEST_* transport/protocol code. */
51
+ errorCode: string;
52
+ runID?: string;
53
+ contractVersion?: string;
54
+ runStatus?: string;
55
+ replayed?: boolean;
56
+ }
57
+ /** No StreamRequest error is automatically retried, including authentication failures. */
58
+ export declare class StreamRequestError extends Error {
59
+ readonly status?: number;
60
+ readonly errorCode: string;
61
+ readonly runID?: string;
62
+ readonly contractVersion?: string;
63
+ readonly runStatus?: string;
64
+ readonly replayed?: boolean;
65
+ readonly retryable = false;
66
+ readonly outcomeUnknown: boolean;
67
+ constructor(message: string, info: StreamRequestErrorInfo);
68
+ }
69
+ /** Execution may have happened. Reconcile run information; any deliberate replay must reuse the same key. */
70
+ export declare class StreamRequestResultUnknownError extends StreamRequestError {
71
+ readonly outcomeUnknown = true;
72
+ constructor(info: StreamRequestErrorInfo);
73
+ }
74
+ export interface StreamRequestHandle<Input = StreamJSON, Result = StreamJSON> {
75
+ describe(): Promise<PublicStreamRequest>;
76
+ /**
77
+ * One POST only. Input is opaque business JSON, including fields named streamId,
78
+ * entryId, deploymentVersion or timeoutMs. Only the server chooses binding/version/timeout.
79
+ * Generic types are caller assertions; the server validates the contract schemas.
80
+ */
81
+ invoke(input: Input, options?: StreamRequestInvokeOptions): Promise<StreamRequestInvokeResponse<Result>>;
82
+ }
83
+ export declare class StreamRequestsClient {
84
+ private readonly transport;
85
+ constructor(transport?: StreamTransport);
86
+ private post;
87
+ /** Discover visible contracts; defaults and authorization are resolved by the server. */
88
+ discover(options?: StreamRequestDiscoverOptions): Promise<StreamRequestDiscoverResponse>;
89
+ use<Input = StreamJSON, Result = StreamJSON>(selector: {
90
+ code: string;
91
+ }): StreamRequestHandle<Input, Result>;
92
+ }
93
+ export {};
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamRequestsClient = exports.StreamRequestResultUnknownError = exports.StreamRequestError = exports.DEFAULT_STREAM_REQUEST_TRANSPORT_TIMEOUT_MS = void 0;
4
+ const transport_js_1 = require("./transport.js");
5
+ exports.DEFAULT_STREAM_REQUEST_TRANSPORT_TIMEOUT_MS = transport_js_1.DEFAULT_STREAM_TRANSPORT_TIMEOUT_MS;
6
+ /** No StreamRequest error is automatically retried, including authentication failures. */
7
+ class StreamRequestError extends Error {
8
+ status;
9
+ errorCode;
10
+ runID;
11
+ contractVersion;
12
+ runStatus;
13
+ replayed;
14
+ retryable = false;
15
+ outcomeUnknown = false;
16
+ constructor(message, info) {
17
+ super(message);
18
+ this.name = 'StreamRequestError';
19
+ this.status = info.status;
20
+ this.errorCode = info.errorCode;
21
+ this.runID = info.runID;
22
+ this.contractVersion = info.contractVersion;
23
+ this.runStatus = info.runStatus;
24
+ this.replayed = info.replayed;
25
+ }
26
+ }
27
+ exports.StreamRequestError = StreamRequestError;
28
+ /** Execution may have happened. Reconcile run information; any deliberate replay must reuse the same key. */
29
+ class StreamRequestResultUnknownError extends StreamRequestError {
30
+ outcomeUnknown = true;
31
+ constructor(info) {
32
+ super('StreamRequest result is unknown; execution may have occurred. Do not automatically retry.', info);
33
+ this.name = 'StreamRequestResultUnknownError';
34
+ }
35
+ }
36
+ exports.StreamRequestResultUnknownError = StreamRequestResultUnknownError;
37
+ function record(value) {
38
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
39
+ }
40
+ function keys(value, allowed) {
41
+ if (!record(value) || Reflect.ownKeys(value).some(key => typeof key !== 'string' || !allowed.includes(key))) {
42
+ throw new TypeError('Tier0 SDK: unsupported StreamRequest option.');
43
+ }
44
+ }
45
+ function json(value, seen = new Set()) {
46
+ if (value === null || typeof value === 'string' || typeof value === 'boolean')
47
+ return true;
48
+ if (typeof value === 'number')
49
+ return Number.isFinite(value);
50
+ if (typeof value !== 'object' || seen.has(value))
51
+ return false;
52
+ if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) {
53
+ return false;
54
+ }
55
+ seen.add(value);
56
+ const valid = (Array.isArray(value) ? Array.from(value) : Object.values(value)).every(item => json(item, seen));
57
+ seen.delete(value);
58
+ return valid;
59
+ }
60
+ function definition(value) {
61
+ if (!record(value))
62
+ return false;
63
+ return ['code', 'name', 'description', 'contractVersion', 'status'].every(key => typeof value[key] === 'string') &&
64
+ value.code !== '' && value.contractVersion !== '' && record(value.inputSchema) && record(value.outputSchema) &&
65
+ ['read', 'write'].includes(value.sideEffect) &&
66
+ ['none', 'optional', 'required'].includes(value.idempotency) &&
67
+ typeof value.timeoutMs === 'number' && Number.isSafeInteger(value.timeoutMs) && value.timeoutMs > 0;
68
+ }
69
+ function runInfo(value) {
70
+ if (!record(value))
71
+ return {};
72
+ return {
73
+ runID: typeof value.runID === 'string' ? value.runID : undefined,
74
+ contractVersion: typeof value.contractVersion === 'string' ? value.contractVersion : undefined,
75
+ runStatus: typeof value.status === 'string' ? value.status : undefined,
76
+ replayed: typeof value.replayed === 'boolean' ? value.replayed : undefined,
77
+ };
78
+ }
79
+ class StreamRequestsClient {
80
+ transport;
81
+ constructor(transport = new transport_js_1.StreamTransport()) {
82
+ this.transport = transport;
83
+ }
84
+ async post(path, body, invoked) {
85
+ let response;
86
+ try {
87
+ response = await this.transport.post(path, body);
88
+ }
89
+ catch (error) {
90
+ if (!(error instanceof transport_js_1.StreamTransportError))
91
+ throw error;
92
+ const info = { status: error.status, errorCode: `STREAM_REQUEST_${error.kind}` };
93
+ if (invoked)
94
+ throw new StreamRequestResultUnknownError(info);
95
+ const message = error.kind === 'TRANSPORT_TIMEOUT' ? 'StreamRequest HTTP transport deadline exceeded.' :
96
+ error.kind === 'PROTOCOL_ERROR' ? 'Invalid StreamRequest response.' : 'StreamRequest transport failed.';
97
+ throw new StreamRequestError(message, info);
98
+ }
99
+ const { value, status, ok } = response;
100
+ if (!ok) {
101
+ const error = record(value) ? value : {};
102
+ const valid = typeof error.errorCode === 'string' && typeof error.message === 'string';
103
+ const info = {
104
+ ...runInfo(value), status,
105
+ errorCode: valid ? error.errorCode : 'STREAM_REQUEST_PROTOCOL_ERROR',
106
+ };
107
+ if (info.errorCode === 'STREAM_REQUEST_RESULT_UNKNOWN' || (invoked && !valid)) {
108
+ throw new StreamRequestResultUnknownError(info);
109
+ }
110
+ throw new StreamRequestError(valid ? error.message : 'Invalid StreamRequest error response.', info);
111
+ }
112
+ return { value, status };
113
+ }
114
+ /** Discover visible contracts; defaults and authorization are resolved by the server. */
115
+ async discover(options = {}) {
116
+ keys(options, ['page', 'size', 'search']);
117
+ if ((options.page !== undefined && (!Number.isSafeInteger(options.page) || options.page < 1)) ||
118
+ (options.size !== undefined && (!Number.isSafeInteger(options.size) || options.size < 1 || options.size > 200)) ||
119
+ (options.search !== undefined && typeof options.search !== 'string')) {
120
+ throw new TypeError('Tier0 SDK: invalid StreamRequest discovery options.');
121
+ }
122
+ const { value, status } = await this.post('/openapi/v2/stream-requests/discover', options, false);
123
+ if (!record(value) || !Number.isSafeInteger(value.total) || value.total < 0 ||
124
+ !Array.isArray(value.list) || !value.list.every(definition)) {
125
+ throw new StreamRequestError('Invalid StreamRequest discovery response.', { status, errorCode: 'STREAM_REQUEST_PROTOCOL_ERROR' });
126
+ }
127
+ return value;
128
+ }
129
+ use(selector) {
130
+ keys(selector, ['code']);
131
+ const code = selector.code;
132
+ if (typeof code !== 'string' || code.length > 128 || !/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(code)) {
133
+ throw new TypeError('Tier0 SDK: invalid StreamRequest code.');
134
+ }
135
+ const path = `/openapi/v2/stream-requests/${encodeURIComponent(code)}`;
136
+ return {
137
+ describe: async () => {
138
+ const { value, status } = await this.post(`${path}/describe`, {}, false);
139
+ if (!definition(value) || value.code !== code) {
140
+ throw new StreamRequestError('Invalid StreamRequest description.', { status, errorCode: 'STREAM_REQUEST_PROTOCOL_ERROR' });
141
+ }
142
+ return value;
143
+ },
144
+ invoke: async (input, options = {}) => {
145
+ keys(options, ['idempotencyKey']);
146
+ const key = options.idempotencyKey;
147
+ if (key !== undefined && (typeof key !== 'string' || !key || key.trim() !== key || new TextEncoder().encode(key).length > 128)) {
148
+ throw new TypeError('Tier0 SDK: invalid StreamRequest idempotency key.');
149
+ }
150
+ if (!json(input))
151
+ throw new TypeError('Tier0 SDK: StreamRequest input must be JSON.');
152
+ const { value, status } = await this.post(`${path}/invoke`, {
153
+ input, ...(key === undefined ? {} : { idempotencyKey: key }),
154
+ }, true);
155
+ if (!record(value) || value.code !== code || typeof value.contractVersion !== 'string' || !value.contractVersion ||
156
+ !Object.prototype.hasOwnProperty.call(value, 'result') || typeof value.runID !== 'string' || !value.runID ||
157
+ value.status !== 'completed' ||
158
+ typeof value.replayed !== 'boolean') {
159
+ throw new StreamRequestResultUnknownError({ ...runInfo(value), status, errorCode: 'STREAM_REQUEST_PROTOCOL_ERROR' });
160
+ }
161
+ return value;
162
+ },
163
+ };
164
+ }
165
+ }
166
+ exports.StreamRequestsClient = StreamRequestsClient;
167
+ //# sourceMappingURL=requests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requests.js","sourceRoot":"","sources":["../../../src/streams/requests.ts"],"names":[],"mappings":";;;AAAA,iDAAwI;AAiC3H,QAAA,2CAA2C,GAAG,kDAAmC,CAAC;AA6B/F,0FAA0F;AAC1F,MAAa,kBAAmB,SAAQ,KAAK;IAClC,MAAM,CAAU;IAChB,SAAS,CAAS;IAClB,KAAK,CAAU;IACf,eAAe,CAAU;IACzB,SAAS,CAAU;IACnB,QAAQ,CAAW;IACnB,SAAS,GAAG,KAAK,CAAC;IAClB,cAAc,GAAY,KAAK,CAAC;IAEzC,YAAY,OAAe,EAAE,IAA4B;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC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MEOUT_MS, type StreamTransportConfig } from './transport.js';\nimport type { components } from './contract.generated.js';\n/** Public request contracts do not expose runtime bindings. */\nexport type StreamJSON = null | boolean | number | string | StreamJSON[] | { [key: string]: StreamJSON };\n\nexport interface PublicStreamRequest extends Omit<components['schemas']['PublicStreamRequest'], 'inputSchema' | 'outputSchema' | 'sideEffect' | 'idempotency'> {\n code: string;\n name: string;\n description: string;\n contractVersion: string;\n inputSchema: Record<string, StreamJSON>;\n outputSchema: Record<string, StreamJSON>;\n sideEffect: 'read' | 'write';\n idempotency: 'none' | 'optional' | 'required';\n timeoutMs: number;\n status: string;\n}\n\ntype WireDiscovery = components['schemas']['StreamRequestDiscoverReq'];\nexport interface StreamRequestDiscoverOptions extends WireDiscovery {\n page?: number;\n size?: number;\n search?: string;\n}\n\nexport interface StreamRequestDiscoverResponse {\n total: number;\n list: PublicStreamRequest[];\n}\n\n/** HTTP transport settings do not override server execution semantics. */\nexport interface StreamRequestTransportConfig extends StreamTransportConfig {}\n\nexport const DEFAULT_STREAM_REQUEST_TRANSPORT_TIMEOUT_MS = DEFAULT_STREAM_TRANSPORT_TIMEOUT_MS;\n\nexport interface StreamRequestInvokeOptions {\n /** Stable caller-owned key for one business intent, at most 128 UTF-8 bytes. Never generated or retried by the SDK. */\n idempotencyKey?: string;\n}\n\nexport interface StreamRequestInvokeResponse<Result = StreamJSON> extends Omit<components['schemas']['StreamRequestInvokeResp'], 'result' | 'status'> {\n code: string;\n contractVersion: string;\n result: Result;\n runID: string;\n /** Persisted request ledger success; all other states reject conservatively. */\n status: 'completed';\n /** True only when the server explicitly reports an idempotent replay. */\n replayed: boolean;\n}\n\nexport interface StreamRequestErrorInfo {\n /** HTTP status, absent when no HTTP response was received. */\n status?: number;\n /** Gateway string errorCode, or an SDK-local STREAM_REQUEST_* transport/protocol code. */\n errorCode: string;\n runID?: string;\n contractVersion?: string;\n runStatus?: string;\n replayed?: boolean;\n}\n\n/** No StreamRequest error is automatically retried, including authentication failures. */\nexport class StreamRequestError extends Error {\n readonly status?: number;\n readonly errorCode: string;\n readonly runID?: string;\n readonly contractVersion?: string;\n readonly runStatus?: string;\n readonly replayed?: boolean;\n readonly retryable = false;\n readonly outcomeUnknown: boolean = false;\n\n constructor(message: string, info: StreamRequestErrorInfo) {\n super(message);\n this.name = 'StreamRequestError';\n this.status = info.status;\n this.errorCode = info.errorCode;\n this.runID = info.runID;\n this.contractVersion = info.contractVersion;\n this.runStatus = info.runStatus;\n this.replayed = info.replayed;\n }\n}\n\n/** Execution may have happened. Reconcile run information; any deliberate replay must reuse the same key. */\nexport class StreamRequestResultUnknownError extends StreamRequestError {\n readonly outcomeUnknown = true;\n\n constructor(info: StreamRequestErrorInfo) {\n super('StreamRequest result is unknown; execution may have occurred. Do not automatically retry.', info);\n this.name = 'StreamRequestResultUnknownError';\n }\n}\n\nfunction record(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction keys(value: unknown, allowed: string[]): void {\n if (!record(value) || Reflect.ownKeys(value).some(key => typeof key !== 'string' || !allowed.includes(key))) {\n throw new TypeError('Tier0 SDK: unsupported StreamRequest option.');\n }\n}\n\nfunction json(value: unknown, seen = new Set<unknown>()): boolean {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object' || seen.has(value)) return false;\n if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) {\n return false;\n }\n seen.add(value);\n const valid = (Array.isArray(value) ? Array.from(value) : Object.values(value)).every(item => json(item, seen));\n seen.delete(value);\n return valid;\n}\n\nfunction definition(value: unknown): value is PublicStreamRequest {\n if (!record(value)) return false;\n return ['code', 'name', 'description', 'contractVersion', 'status'].every(key => typeof value[key] === 'string') &&\n value.code !== '' && value.contractVersion !== '' && record(value.inputSchema) && record(value.outputSchema) &&\n ['read', 'write'].includes(value.sideEffect as string) &&\n ['none', 'optional', 'required'].includes(value.idempotency as string) &&\n typeof value.timeoutMs === 'number' && Number.isSafeInteger(value.timeoutMs) && value.timeoutMs > 0;\n}\n\nfunction runInfo(value: unknown): Partial<StreamRequestErrorInfo> {\n if (!record(value)) return {};\n return {\n runID: typeof value.runID === 'string' ? value.runID : undefined,\n contractVersion: typeof value.contractVersion === 'string' ? value.contractVersion : undefined,\n runStatus: typeof value.status === 'string' ? value.status : undefined,\n replayed: typeof value.replayed === 'boolean' ? value.replayed : undefined,\n };\n}\n\nexport interface StreamRequestHandle<Input = StreamJSON, Result = StreamJSON> {\n describe(): Promise<PublicStreamRequest>;\n /**\n * One POST only. Input is opaque business JSON, including fields named streamId,\n * entryId, deploymentVersion or timeoutMs. Only the server chooses binding/version/timeout.\n * Generic types are caller assertions; the server validates the contract schemas.\n */\n invoke(input: Input, options?: StreamRequestInvokeOptions): Promise<StreamRequestInvokeResponse<Result>>;\n}\n\nexport class StreamRequestsClient {\n private readonly transport: StreamTransport;\n\n constructor(transport = new StreamTransport()) {\n this.transport = transport;\n }\n\n private async post(path: string, body: unknown, invoked: boolean): Promise<{ value: unknown; status: number }> {\n let response: Awaited<ReturnType<StreamTransport['post']>>;\n try {\n response = await this.transport.post(path, body);\n } catch (error) {\n if (!(error instanceof StreamTransportError)) throw error;\n const info = { status: error.status, errorCode: `STREAM_REQUEST_${error.kind}` };\n if (invoked) throw new StreamRequestResultUnknownError(info);\n const message = error.kind === 'TRANSPORT_TIMEOUT' ? 'StreamRequest HTTP transport deadline exceeded.' :\n error.kind === 'PROTOCOL_ERROR' ? 'Invalid StreamRequest response.' : 'StreamRequest transport failed.';\n throw new StreamRequestError(message, info);\n }\n const { value, status, ok } = response;\n if (!ok) {\n const error = record(value) ? value : {};\n const valid = typeof error.errorCode === 'string' && typeof error.message === 'string';\n const info: StreamRequestErrorInfo = {\n ...runInfo(value), status,\n errorCode: valid ? error.errorCode as string : 'STREAM_REQUEST_PROTOCOL_ERROR',\n };\n if (info.errorCode === 'STREAM_REQUEST_RESULT_UNKNOWN' || (invoked && !valid)) {\n throw new StreamRequestResultUnknownError(info);\n }\n throw new StreamRequestError(valid ? error.message as string : 'Invalid StreamRequest error response.', info);\n }\n return { value, status };\n }\n\n /** Discover visible contracts; defaults and authorization are resolved by the server. */\n async discover(options: StreamRequestDiscoverOptions = {}): Promise<StreamRequestDiscoverResponse> {\n keys(options, ['page', 'size', 'search']);\n if ((options.page !== undefined && (!Number.isSafeInteger(options.page) || options.page < 1)) ||\n (options.size !== undefined && (!Number.isSafeInteger(options.size) || options.size < 1 || options.size > 200)) ||\n (options.search !== undefined && typeof options.search !== 'string')) {\n throw new TypeError('Tier0 SDK: invalid StreamRequest discovery options.');\n }\n const { value, status } = await this.post('/openapi/v2/stream-requests/discover', options, false);\n if (!record(value) || !Number.isSafeInteger(value.total) || (value.total as number) < 0 ||\n !Array.isArray(value.list) || !value.list.every(definition)) {\n throw new StreamRequestError('Invalid StreamRequest discovery response.', { status, errorCode: 'STREAM_REQUEST_PROTOCOL_ERROR' });\n }\n return value as unknown as StreamRequestDiscoverResponse;\n }\n\n use<Input = StreamJSON, Result = StreamJSON>(selector: { code: string }): StreamRequestHandle<Input, Result> {\n keys(selector, ['code']);\n const code = selector.code;\n if (typeof code !== 'string' || code.length > 128 || !/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(code)) {\n throw new TypeError('Tier0 SDK: invalid StreamRequest code.');\n }\n const path = `/openapi/v2/stream-requests/${encodeURIComponent(code)}`;\n return {\n describe: async () => {\n const { value, status } = await this.post(`${path}/describe`, {}, false);\n if (!definition(value) || value.code !== code) {\n throw new StreamRequestError('Invalid StreamRequest description.', { status, errorCode: 'STREAM_REQUEST_PROTOCOL_ERROR' });\n }\n return value;\n },\n invoke: async (input, options = {}) => {\n keys(options, ['idempotencyKey']);\n const key = options.idempotencyKey;\n if (key !== undefined && (typeof key !== 'string' || !key || key.trim() !== key || new TextEncoder().encode(key).length > 128)) {\n throw new TypeError('Tier0 SDK: invalid StreamRequest idempotency key.');\n }\n if (!json(input)) throw new TypeError('Tier0 SDK: StreamRequest input must be JSON.');\n const { value, status } = await this.post(`${path}/invoke`, {\n input, ...(key === undefined ? {} : { idempotencyKey: key }),\n }, true);\n if (!record(value) || value.code !== code || typeof value.contractVersion !== 'string' || !value.contractVersion ||\n !Object.prototype.hasOwnProperty.call(value, 'result') || typeof value.runID !== 'string' || !value.runID ||\n value.status !== 'completed' ||\n typeof value.replayed !== 'boolean') {\n throw new StreamRequestResultUnknownError({ ...runInfo(value), status, errorCode: 'STREAM_REQUEST_PROTOCOL_ERROR' });\n }\n return value as unknown as StreamRequestInvokeResponse<Result>;\n },\n };\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { type HttpClient } from '../openapi/client.js';
2
+ import { type AppRuntime } from '../runtime.js';
3
+ import { CloudTransport, CloudTransportError, type CloudTransportConfig } from '../cloud-transport.js';
4
+ export type StreamTransportConfig = Pick<CloudTransportConfig, 'transportTimeoutMs'>;
5
+ export declare const DEFAULT_STREAM_TRANSPORT_TIMEOUT_MS = 60000;
6
+ export { CloudTransportError as StreamTransportError };
7
+ /** Add the trusted App bridge to the existing single-attempt Cloud transport. */
8
+ export declare class StreamTransport extends CloudTransport {
9
+ readonly runtime: () => AppRuntime | undefined;
10
+ constructor(resolveClient?: () => HttpClient, config?: StreamTransportConfig, runtime?: () => AppRuntime | undefined);
11
+ post(path: string, body: unknown, signal?: AbortSignal): Promise<{
12
+ value: unknown;
13
+ status: number;
14
+ ok: boolean;
15
+ }>;
16
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamTransport = exports.StreamTransportError = exports.DEFAULT_STREAM_TRANSPORT_TIMEOUT_MS = void 0;
4
+ const client_js_1 = require("../openapi/client.js");
5
+ const runtime_js_1 = require("../runtime.js");
6
+ const cloud_transport_js_1 = require("../cloud-transport.js");
7
+ Object.defineProperty(exports, "StreamTransportError", { enumerable: true, get: function () { return cloud_transport_js_1.CloudTransportError; } });
8
+ exports.DEFAULT_STREAM_TRANSPORT_TIMEOUT_MS = cloud_transport_js_1.DEFAULT_CLOUD_TRANSPORT_TIMEOUT_MS;
9
+ /** Add the trusted App bridge to the existing single-attempt Cloud transport. */
10
+ class StreamTransport extends cloud_transport_js_1.CloudTransport {
11
+ runtime;
12
+ constructor(resolveClient = client_js_1.getClient, config = {}, runtime = runtime_js_1.getAppRuntime) {
13
+ super(resolveClient, config);
14
+ this.runtime = runtime;
15
+ }
16
+ async post(path, body, signal) {
17
+ const runtime = this.runtime();
18
+ if (!runtime && typeof window !== 'undefined')
19
+ throw new cloud_transport_js_1.CloudTransportError('TRANSPORT_ERROR');
20
+ return super.post(path, body, signal, runtime);
21
+ }
22
+ }
23
+ exports.StreamTransport = StreamTransport;
24
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/streams/transport.ts"],"names":[],"mappings":";;;AAAA,oDAAkE;AAClE,8CAA+D;AAC/D,8DAA2I;AAI3G,qGAJP,wCAAmB,OAIQ;AADvC,QAAA,mCAAmC,GAAG,uDAAkC,CAAC;AAGtF,iFAAiF;AACjF,MAAa,eAAgB,SAAQ,mCAAc;IAItC;IAHX,YACE,gBAAkC,qBAAS,EAC3C,SAAgC,EAAE,EACzB,UAAwC,0BAAa;QAE9D,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAFpB,YAAO,GAAP,OAAO,CAA8C;IAGhE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,IAAa,EAAE,MAAoB;QAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,OAAO,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,MAAM,IAAI,wCAAmB,CAAC,iBAAiB,CAAC,CAAC;QAChG,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;CACF;AAdD,0CAcC","sourcesContent":["import { getClient, type HttpClient } from '../openapi/client.js';\nimport { getAppRuntime, type AppRuntime } from '../runtime.js';\nimport { CloudTransport, CloudTransportError, DEFAULT_CLOUD_TRANSPORT_TIMEOUT_MS, type CloudTransportConfig } from '../cloud-transport.js';\n\nexport type StreamTransportConfig = Pick<CloudTransportConfig, 'transportTimeoutMs'>;\nexport const DEFAULT_STREAM_TRANSPORT_TIMEOUT_MS = DEFAULT_CLOUD_TRANSPORT_TIMEOUT_MS;\nexport { CloudTransportError as StreamTransportError };\n\n/** Add the trusted App bridge to the existing single-attempt Cloud transport. */\nexport class StreamTransport extends CloudTransport {\n constructor(\n resolveClient: () => HttpClient = getClient,\n config: StreamTransportConfig = {},\n readonly runtime: () => AppRuntime | undefined = getAppRuntime,\n ) {\n super(resolveClient, config);\n }\n\n async post(path: string, body: unknown, signal?: AbortSignal) {\n const runtime = this.runtime();\n if (!runtime && typeof window !== 'undefined') throw new CloudTransportError('TRANSPORT_ERROR');\n return super.post(path, body, signal, runtime);\n }\n}\n"]}
@@ -29,8 +29,10 @@ export type UnsV2FieldOperation = ({
29
29
  }) | ({
30
30
  "op"?: "append" | "addToSet";
31
31
  "value"?: Array<UnsV2JSONValue>;
32
- }) | ({
32
+ }) | (({
33
33
  "op"?: "unset";
34
+ }) & {
35
+ "value"?: never;
34
36
  }));
35
37
  export type UnsV2ResultBinding = {
36
38
  "path": string;
@@ -64,8 +66,10 @@ export type UnsV2PipelinePage = ({
64
66
  "mode"?: "offset" | "cursor";
65
67
  "page"?: UnsV2Integer;
66
68
  "cursor"?: string;
67
- }) & ((({
69
+ }) & (((({
68
70
  "mode": "cursor";
71
+ }) & {
72
+ "page"?: never;
69
73
  }) | ({
70
74
  "mode"?: "offset";
71
75
  })));
@@ -392,7 +396,7 @@ export type TransactionQueryResult = {
392
396
  };
393
397
  export type UnsV2SourceStateUpdateReq = {
394
398
  "idempotencyKey"?: string;
395
- "dryRun": boolean;
399
+ "dryRun"?: boolean;
396
400
  "allowPartial"?: false;
397
401
  "mode"?: "auto" | "sync";
398
402
  "items": (Array<({
@@ -508,7 +512,7 @@ export type UnsV2StreamProgramVersionsListResponse = {
508
512
  };
509
513
  export type UnsV2StreamProgramDeployReq = {
510
514
  "idempotencyKey"?: string;
511
- "dryRun": boolean;
515
+ "dryRun"?: boolean;
512
516
  "id": string;
513
517
  "expectedRevision"?: UnsV2Integer;
514
518
  "expectedSourceRevision"?: UnsV2Integer;
@@ -722,8 +726,10 @@ export type UnsV2RecordChange = ({
722
726
  "conditions"?: UnsV2JSONValue;
723
727
  }))) & ((({
724
728
  "selection": "first";
725
- }) | ({
729
+ }) | (({
726
730
  "selection"?: "exactOne";
731
+ }) & {
732
+ "sort"?: never;
727
733
  }))) & ((({
728
734
  "upsert"?: false;
729
735
  }) | ({
@@ -908,8 +914,10 @@ export type UnsV2PipelineStage = (({
908
914
  "pipeline"?: Array<UnsV2PipelineStage>;
909
915
  }) & (({
910
916
  "kind": "samples";
911
- }) | ({
917
+ }) | (({
912
918
  "kind"?: "records";
919
+ }) & {
920
+ "recordId"?: never;
913
921
  })));
914
922
  }) | ({
915
923
  "$unwind": ((string | ({
@@ -1395,7 +1403,7 @@ export type CloudSourceConfig = (({
1395
1403
  export type CloudSourceDocument = ({
1396
1404
  "name": string;
1397
1405
  "description"?: string;
1398
- "protocol": "http-api" | "modbus" | "mqtt" | "opcua" | "sap" | "teamcenter" | "mqtt_device" | "sql";
1406
+ "protocol": "http-api" | "modbus" | "mqtt" | "opcua" | "sap" | "teamcenter" | "mqtt_device" | "sql" | "edge";
1399
1407
  "config": CloudSourceConfig;
1400
1408
  });
1401
1409
  export type CloudStreamRequestDefinition = {
@@ -1528,7 +1536,7 @@ export type CloudSourceDocumentGetResponse = {
1528
1536
  "data": ((CloudSourceDocumentView | CloudSourceDocumentSummary));
1529
1537
  };
1530
1538
  export type CloudSourceDocumentCreateReq = ({
1531
- "dryRun": boolean;
1539
+ "dryRun"?: boolean;
1532
1540
  "idempotencyKey"?: string;
1533
1541
  "document"?: CloudSourceDocument;
1534
1542
  "credentials"?: CloudSourceCreateCredentials;
@@ -1544,7 +1552,7 @@ export type CloudSourceDocumentCreateResponse = {
1544
1552
  "data": ((CloudSourceDocumentView | CloudPreviewResult | Outcome));
1545
1553
  };
1546
1554
  export type CloudSourceDocumentUpdateReq = ({
1547
- "dryRun": boolean;
1555
+ "dryRun"?: boolean;
1548
1556
  "idempotencyKey"?: string;
1549
1557
  "id"?: string;
1550
1558
  "expectedRevision"?: UnsV2Integer;
@@ -1576,7 +1584,7 @@ export type CloudStreamDocumentGetResponse = {
1576
1584
  "data": ((CloudStreamDocumentView | CloudStreamDocumentSummary));
1577
1585
  };
1578
1586
  export type CloudStreamDocumentCreateReq = ({
1579
- "dryRun": boolean;
1587
+ "dryRun"?: boolean;
1580
1588
  "idempotencyKey"?: string;
1581
1589
  "document"?: CloudStreamDocument;
1582
1590
  "program"?: RuntimeStreamDefinition;
@@ -1589,7 +1597,7 @@ export type CloudStreamDocumentCreateResponse = {
1589
1597
  "data": ((CloudStreamDocumentView | CloudPreviewResult));
1590
1598
  };
1591
1599
  export type CloudStreamDocumentUpdateReq = ({
1592
- "dryRun": boolean;
1600
+ "dryRun"?: boolean;
1593
1601
  "idempotencyKey"?: string;
1594
1602
  "id": string;
1595
1603
  "expectedRevision"?: UnsV2Integer;
@@ -1611,7 +1619,7 @@ export type CloudSourceDocumentListReq = {
1611
1619
  "page"?: UnsV2Integer;
1612
1620
  "size"?: UnsV2Integer;
1613
1621
  "search"?: string;
1614
- "protocol"?: "http-api" | "modbus" | "mqtt" | "opcua" | "sap" | "teamcenter" | "mqtt_device" | "sql";
1622
+ "protocol"?: "http-api" | "modbus" | "mqtt" | "opcua" | "sap" | "teamcenter" | "mqtt_device" | "sql" | "edge";
1615
1623
  "desiredState"?: "enabled" | "disabled";
1616
1624
  "health"?: string;
1617
1625
  "archived"?: boolean;
@@ -2354,10 +2362,14 @@ export type UnsV2RecordUnlockReq = ({
2354
2362
  })>);
2355
2363
  "ids"?: Array<string>;
2356
2364
  "force"?: boolean;
2357
- }) & (({
2365
+ }) & ((({
2358
2366
  "force"?: false;
2359
- }) | ({
2367
+ }) & {
2368
+ "ids"?: never;
2369
+ }) | (({
2360
2370
  "force": true;
2371
+ }) & {
2372
+ "locks"?: never;
2361
2373
  }));
2362
2374
  export type UnsV2RecordUnlockResponse = {
2363
2375
  "code": UnsV2Integer;
@@ -2576,7 +2588,7 @@ export type CloudStreamRunError = {
2576
2588
  };
2577
2589
  export type CloudSourceCreateCredentials = ({
2578
2590
  "method"?: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "REQUEST";
2579
- "kind": "basic" | "bearer" | "apiKey" | "oauth2ClientCredentials";
2591
+ "kind": "basic" | "bearer" | "apiKey" | "oauth2ClientCredentials" | "usernamePassword";
2580
2592
  "material": {};
2581
2593
  }) & (({
2582
2594
  "kind"?: "basic";
@@ -2606,6 +2618,14 @@ export type CloudSourceCreateCredentials = ({
2606
2618
  "scope"?: string;
2607
2619
  "clientAuthentication"?: "client_secret_post" | "client_secret_basic";
2608
2620
  });
2621
+ }) | (({
2622
+ "kind"?: "usernamePassword";
2623
+ "material"?: ({
2624
+ "username": string;
2625
+ "password": string;
2626
+ });
2627
+ }) & {
2628
+ "method"?: never;
2609
2629
  }));
2610
2630
  export type UnsV2MetadataFindReq = ((({
2611
2631
  "kind": "directory" | "topic" | "collection";
@@ -7085,6 +7105,9 @@ export declare const UNS_V2_CODEC_SCHEMAS: {
7085
7105
  readonly a: readonly [{
7086
7106
  readonly k: "o";
7087
7107
  readonly p: {
7108
+ readonly credentials: {
7109
+ readonly k: "o";
7110
+ };
7088
7111
  readonly document: {
7089
7112
  readonly k: "o";
7090
7113
  readonly p: {
@@ -7094,6 +7117,16 @@ export declare const UNS_V2_CODEC_SCHEMAS: {
7094
7117
  };
7095
7118
  };
7096
7119
  };
7120
+ }, {
7121
+ readonly k: "o";
7122
+ readonly p: {
7123
+ readonly credentials: {
7124
+ readonly k: "o";
7125
+ };
7126
+ readonly document: {
7127
+ readonly k: "o";
7128
+ };
7129
+ };
7097
7130
  }];
7098
7131
  }];
7099
7132
  };
@@ -8879,6 +8912,13 @@ export declare const UNS_V2_CODEC_SCHEMAS: {
8879
8912
  readonly k: "o";
8880
8913
  };
8881
8914
  };
8915
+ }, {
8916
+ readonly k: "o";
8917
+ readonly p: {
8918
+ readonly material: {
8919
+ readonly k: "o";
8920
+ };
8921
+ };
8882
8922
  }];
8883
8923
  };
8884
8924
  readonly UnsV2MetadataFindReq: {
@@ -9774,11 +9814,11 @@ export declare const UNS_V2_CODEC_SCHEMAS: {
9774
9814
  };
9775
9815
  export declare const UNS_V2_CONTRACT_PROVENANCE: {
9776
9816
  readonly repository: "FREEZONEX/Tier0-Backend";
9777
- readonly revision: "7af1912802294d2f4cbe8c92fb0a303a8abda2cf";
9817
+ readonly revision: "5ba6c3af432d5200674f7cb1a3edd31b255ef64b";
9778
9818
  readonly version: "5.0.0";
9779
9819
  readonly source: "service/unssvr/internal/domain/unsv2/contract_generated.go#ContractJSON";
9780
- readonly cloudRevision: "7af1912802294d2f4cbe8c92fb0a303a8abda2cf";
9781
- readonly cloudContractRevision: "cloud-source-impact/2+source-vendor/2+app-create-capability/1+data/3+record-reads/1+stream-receipt/1+stream-run-error/1+collection-namespace/1+business-name/1+http-acquisition/2+http-source-role/1+http-source-request/1+app-collection/2+collection-ownership/1+metadata/1+app-context/3+collection-ttl/1+error-model/1+crud-consolidation/1+record-insert-return/1+lifecycle-consolidation/1+api-surface/2+source-stream-single-model+app-data/2+hosted-control/1+source-bindings/1+record-notifications/1+record-delete-samples/1+stream-history/1+app-collections/1+http-in/1+app-resource-access/2+stream-control-probe-retirement/1+http-push-retirement/1";
9820
+ readonly cloudRevision: "5ba6c3af432d5200674f7cb1a3edd31b255ef64b";
9821
+ readonly cloudContractRevision: "cloud-source-impact/2+source-vendor/2+app-create-capability/1+data/3+record-reads/1+stream-receipt/1+stream-run-error/1+collection-namespace/1+business-name/1+http-acquisition/2+http-source-role/1+http-source-request/1+sql-inline-credentials/1+app-collection/2+collection-ownership/1+metadata/1+app-context/3+collection-ttl/1+error-model/1+crud-consolidation/1+record-insert-return/1+lifecycle-consolidation/1+mutation-defaults/1+api-surface/2+source-stream-single-model+app-data/2+hosted-control/1+source-bindings/1+record-notifications/1+record-delete-samples/1+stream-history/1+app-collections/1+http-in/1+app-resource-access/2+stream-control-probe-retirement/1+http-push-retirement/1";
9782
9822
  readonly resolvedCloudContract: true;
9783
9823
  readonly enterpriseBase: {
9784
9824
  readonly repository: "FREEZONEX/Tier0-Enterprise-New";
@@ -9794,12 +9834,37 @@ export declare const UNS_V2_CONTRACT_PROVENANCE: {
9794
9834
  readonly capability: "x-tier0-opcua-server: static available=false; online availability is workspace/registry authoritative";
9795
9835
  };
9796
9836
  };
9797
- readonly sourceDerivedContractSHA256: "71fd08f483a46d0673389552418a6ca23983ff2a6957803ddba6b71fa9385064";
9837
+ readonly sourceDerivedContractSHA256: "a8c280d90b9d865a80637d7b563bd72611aead54bf0422a0cf83e05feaacd724";
9838
+ readonly schemaUpdates: readonly [{
9839
+ readonly scope: "source-stream-acquisition";
9840
+ readonly repository: "FREEZONEX/Tier0-Backend";
9841
+ readonly revision: "5ba6c3af432d5200674f7cb1a3edd31b255ef64b";
9842
+ readonly sourceKind: "committed";
9843
+ readonly source: "share/unscontract/manifest.json";
9844
+ readonly sourceSHA256: "c92e134799190fda29360a2983692ed47fb421a85fa7d92267ce091ac263dac8";
9845
+ readonly sourceContractRevision: "cloud-source-impact/2+source-vendor/2+app-create-capability/1+data/3+record-reads/1+stream-receipt/1+stream-run-error/1+collection-namespace/1+business-name/1+http-acquisition/2+http-source-role/1+http-source-request/1+sql-inline-credentials/1+app-collection/2+collection-ownership/1+metadata/1+app-context/3+collection-ttl/1+error-model/1+crud-consolidation/1+record-insert-return/1+lifecycle-consolidation/1+mutation-defaults/1+api-surface/2+source-stream-single-model+app-data/2+hosted-control/1+source-bindings/1+record-notifications/1+record-delete-samples/1+stream-history/1+app-collections/1+http-in/1+app-resource-access/2+stream-control-probe-retirement/1+http-push-retirement/1";
9846
+ readonly schemas: readonly ["CloudSourceCreateCredentials", "CloudSourceDocumentCreateReq", "CloudSourceDocumentUpdateReq", "UnsV2SourceStateUpdateReq", "CloudStreamDocumentCreateReq", "CloudStreamDocumentUpdateReq", "UnsV2StreamProgramDeployReq"];
9847
+ readonly inputs: {
9848
+ readonly "contracts/uns-v2/manifest.json": {
9849
+ readonly path: "share/unscontract/manifest.json";
9850
+ readonly sourceSHA256: "c92e134799190fda29360a2983692ed47fb421a85fa7d92267ce091ac263dac8";
9851
+ readonly baseSHA256: "c92e134799190fda29360a2983692ed47fb421a85fa7d92267ce091ac263dac8";
9852
+ readonly resultSHA256: "c92e134799190fda29360a2983692ed47fb421a85fa7d92267ce091ac263dac8";
9853
+ };
9854
+ readonly "contracts/uns-v2/contract.json": {
9855
+ readonly path: "share/unscontract/manifest.json";
9856
+ readonly sourceSHA256: "c92e134799190fda29360a2983692ed47fb421a85fa7d92267ce091ac263dac8";
9857
+ readonly baseSHA256: "a8c280d90b9d865a80637d7b563bd72611aead54bf0422a0cf83e05feaacd724";
9858
+ readonly resultSHA256: "a8c280d90b9d865a80637d7b563bd72611aead54bf0422a0cf83e05feaacd724";
9859
+ };
9860
+ };
9861
+ }];
9862
+ readonly note: "Pinned base with reviewed acquisition schema updates; schemaUpdates records the exact source revision and hashes. Other data-model inputs remain pinned.";
9798
9863
  readonly hashes: {
9799
- readonly contract: "71fd08f483a46d0673389552418a6ca23983ff2a6957803ddba6b71fa9385064";
9864
+ readonly contract: "a8c280d90b9d865a80637d7b563bd72611aead54bf0422a0cf83e05feaacd724";
9800
9865
  readonly cloudSupport: "4ff9d5ff69e35e38459287cf15df45ab627684e2e2294dfd1e076ebc4fc34b46";
9801
- readonly manifest: "f44de4fc45bb0868be9e6cedf5e68dfeca8c708146203830812f419ffc513fde";
9802
- readonly provenance: "2694eaa5c48671f5ca66abc790792094e363e9a765aace0b5aa312aef54f126f";
9866
+ readonly manifest: "c92e134799190fda29360a2983692ed47fb421a85fa7d92267ce091ac263dac8";
9867
+ readonly provenance: "5b80e631aaba726b90ef69845d95e798ff35163c3cf98352e23ee71e4e90bde0";
9803
9868
  readonly registry: "c74313c217742d50391a94c09e60d5c5bd1a89c305fa4145cbf23b35ba7dbcdb";
9804
9869
  };
9805
9870
  readonly publicOperationCount: 82;