@nizam-os/operator-sdk 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,6 +41,7 @@ export declare class FilesClient {
41
41
  * @throws {@link NizamOperatorRuntime.BadRequestError}
42
42
  * @throws {@link NizamOperatorRuntime.UnauthorizedError}
43
43
  * @throws {@link NizamOperatorRuntime.ForbiddenError}
44
+ * @throws {@link NizamOperatorRuntime.ConflictError}
44
45
  * @throws {@link NizamOperatorRuntime.ContentTooLargeError}
45
46
  * @throws {@link NizamOperatorRuntime.UnprocessableEntityError}
46
47
  * @throws {@link NizamOperatorRuntime.TooManyRequestsError}
@@ -48,6 +49,7 @@ export declare class FilesClient {
48
49
  *
49
50
  * @example
50
51
  * await client.files.initiateFileUpload({
52
+ * "Idempotency-Key": "9f1e6d2a-7c3b-4e5f-8a91-0b2c3d4e5f60",
51
53
  * kind: "profile_picture",
52
54
  * subject_type: "task_attempt",
53
55
  * subject_id: "b3c4d5e6-7f8a-9b0c-1d2e-3f4a5b6c7d8e",
@@ -137,6 +137,7 @@ class FilesClient {
137
137
  * @throws {@link NizamOperatorRuntime.BadRequestError}
138
138
  * @throws {@link NizamOperatorRuntime.UnauthorizedError}
139
139
  * @throws {@link NizamOperatorRuntime.ForbiddenError}
140
+ * @throws {@link NizamOperatorRuntime.ConflictError}
140
141
  * @throws {@link NizamOperatorRuntime.ContentTooLargeError}
141
142
  * @throws {@link NizamOperatorRuntime.UnprocessableEntityError}
142
143
  * @throws {@link NizamOperatorRuntime.TooManyRequestsError}
@@ -144,6 +145,7 @@ class FilesClient {
144
145
  *
145
146
  * @example
146
147
  * await client.files.initiateFileUpload({
148
+ * "Idempotency-Key": "9f1e6d2a-7c3b-4e5f-8a91-0b2c3d4e5f60",
147
149
  * kind: "profile_picture",
148
150
  * subject_type: "task_attempt",
149
151
  * subject_id: "b3c4d5e6-7f8a-9b0c-1d2e-3f4a5b6c7d8e",
@@ -157,8 +159,9 @@ class FilesClient {
157
159
  return core.HttpResponsePromise.fromPromise(this.__initiateFileUpload(request, requestOptions));
158
160
  }
159
161
  async __initiateFileUpload(request, requestOptions) {
162
+ const { "Idempotency-Key": idempotencyKey, ..._body } = request;
160
163
  const _authRequest = await this._options.authProvider.getAuthRequest();
161
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, requestOptions?.headers);
164
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "Idempotency-Key": idempotencyKey }), requestOptions?.headers);
162
165
  const _response = await core.fetcher({
163
166
  url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
164
167
  (await core.Supplier.get(this._options.environment)) ??
@@ -168,7 +171,7 @@ class FilesClient {
168
171
  contentType: "application/json",
169
172
  queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
170
173
  requestType: "json",
171
- body: request,
174
+ body: _body,
172
175
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
173
176
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
174
177
  abortSignal: requestOptions?.abortSignal,
@@ -189,6 +192,8 @@ class FilesClient {
189
192
  throw new NizamOperatorRuntime.UnauthorizedError(_response.error.body, _response.rawResponse);
190
193
  case 403:
191
194
  throw new NizamOperatorRuntime.ForbiddenError(_response.error.body, _response.rawResponse);
195
+ case 409:
196
+ throw new NizamOperatorRuntime.ConflictError(_response.error.body, _response.rawResponse);
192
197
  case 413:
193
198
  throw new NizamOperatorRuntime.ContentTooLargeError(_response.error.body, _response.rawResponse);
194
199
  case 422:
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @example
3
3
  * {
4
+ * "Idempotency-Key": "9f1e6d2a-7c3b-4e5f-8a91-0b2c3d4e5f60",
4
5
  * kind: "profile_picture",
5
6
  * subject_type: "task_attempt",
6
7
  * subject_id: "b3c4d5e6-7f8a-9b0c-1d2e-3f4a5b6c7d8e",
@@ -11,6 +12,8 @@
11
12
  * }
12
13
  */
13
14
  export interface InitiateFileUploadRequest {
15
+ /** Optional. Supply a UUID (canonical 8-4-4-4-12 form; lowercase v4 recommended) to make this operation idempotent: the same key on a retry replays the original outcome instead of creating a second resource. 2xx successes and deliberate 4xx domain rejections are cached and replayed for 24h when the request body matches; transient 5xx responses are never cached, so a retry with the same key re-executes. A malformed key is rejected with 400 `idempotency.invalid_key`; reusing a key with a different request body is 409 `idempotency.key_conflict`; a key still in flight is 409 `idempotency.in_progress`. Omit the header and the operation behaves like any other write. */
16
+ "Idempotency-Key"?: string;
14
17
  /** What the bytes are for the platform — fixes the policy applied to them. */
15
18
  kind: InitiateFileUploadRequest.Kind;
16
19
  /** Type of the business entity this file documents (optional at upload time; can also be attached later). */
@@ -42,6 +42,7 @@ export declare class TaskAttemptsClient {
42
42
  * @throws {@link NizamOperatorRuntime.UnauthorizedError}
43
43
  * @throws {@link NizamOperatorRuntime.ForbiddenError}
44
44
  * @throws {@link NizamOperatorRuntime.NotFoundError}
45
+ * @throws {@link NizamOperatorRuntime.ConflictError}
45
46
  * @throws {@link NizamOperatorRuntime.ContentTooLargeError}
46
47
  * @throws {@link NizamOperatorRuntime.UnprocessableEntityError}
47
48
  * @throws {@link NizamOperatorRuntime.TooManyRequestsError}
@@ -49,6 +50,7 @@ export declare class TaskAttemptsClient {
49
50
  *
50
51
  * @example
51
52
  * await client.taskAttempts.captureTaskAttemptPhoto({
53
+ * "Idempotency-Key": "9f1e6d2a-7c3b-4e5f-8a91-0b2c3d4e5f60",
52
54
  * attemptId: "00000000-0000-0000-0000-000000000000",
53
55
  * filename: "delivery-door.jpg",
54
56
  * content_type: "image/jpeg",
@@ -135,6 +135,7 @@ class TaskAttemptsClient {
135
135
  * @throws {@link NizamOperatorRuntime.UnauthorizedError}
136
136
  * @throws {@link NizamOperatorRuntime.ForbiddenError}
137
137
  * @throws {@link NizamOperatorRuntime.NotFoundError}
138
+ * @throws {@link NizamOperatorRuntime.ConflictError}
138
139
  * @throws {@link NizamOperatorRuntime.ContentTooLargeError}
139
140
  * @throws {@link NizamOperatorRuntime.UnprocessableEntityError}
140
141
  * @throws {@link NizamOperatorRuntime.TooManyRequestsError}
@@ -142,6 +143,7 @@ class TaskAttemptsClient {
142
143
  *
143
144
  * @example
144
145
  * await client.taskAttempts.captureTaskAttemptPhoto({
146
+ * "Idempotency-Key": "9f1e6d2a-7c3b-4e5f-8a91-0b2c3d4e5f60",
145
147
  * attemptId: "00000000-0000-0000-0000-000000000000",
146
148
  * filename: "delivery-door.jpg",
147
149
  * content_type: "image/jpeg",
@@ -157,9 +159,9 @@ class TaskAttemptsClient {
157
159
  return core.HttpResponsePromise.fromPromise(this.__captureTaskAttemptPhoto(request, requestOptions));
158
160
  }
159
161
  async __captureTaskAttemptPhoto(request, requestOptions) {
160
- const { attemptId, ..._body } = request;
162
+ const { attemptId, "Idempotency-Key": idempotencyKey, ..._body } = request;
161
163
  const _authRequest = await this._options.authProvider.getAuthRequest();
162
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, requestOptions?.headers);
164
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "Idempotency-Key": idempotencyKey }), requestOptions?.headers);
163
165
  const _response = await core.fetcher({
164
166
  url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
165
167
  (await core.Supplier.get(this._options.environment)) ??
@@ -192,6 +194,8 @@ class TaskAttemptsClient {
192
194
  throw new NizamOperatorRuntime.ForbiddenError(_response.error.body, _response.rawResponse);
193
195
  case 404:
194
196
  throw new NizamOperatorRuntime.NotFoundError(_response.error.body, _response.rawResponse);
197
+ case 409:
198
+ throw new NizamOperatorRuntime.ConflictError(_response.error.body, _response.rawResponse);
195
199
  case 413:
196
200
  throw new NizamOperatorRuntime.ContentTooLargeError(_response.error.body, _response.rawResponse);
197
201
  case 422:
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @example
3
3
  * {
4
+ * "Idempotency-Key": "9f1e6d2a-7c3b-4e5f-8a91-0b2c3d4e5f60",
4
5
  * attemptId: "00000000-0000-0000-0000-000000000000",
5
6
  * filename: "delivery-door.jpg",
6
7
  * content_type: "image/jpeg",
@@ -14,6 +15,8 @@
14
15
  */
15
16
  export interface CaptureTaskAttemptPhotoRequest {
16
17
  attemptId: string;
18
+ /** Optional. Supply a UUID (canonical 8-4-4-4-12 form; lowercase v4 recommended) to make this operation idempotent: the same key on a retry replays the original outcome instead of creating a second resource. 2xx successes and deliberate 4xx domain rejections are cached and replayed for 24h when the request body matches; transient 5xx responses are never cached, so a retry with the same key re-executes. A malformed key is rejected with 400 `idempotency.invalid_key`; reusing a key with a different request body is 409 `idempotency.key_conflict`; a key still in flight is 409 `idempotency.in_progress`. Omit the header and the operation behaves like any other write. */
19
+ "Idempotency-Key"?: string;
17
20
  /** Original filename. */
18
21
  filename: string;
19
22
  /** Declared MIME type — POD photos accept image/jpeg, image/png, image/webp, image/heic, image/heif. */
@@ -5,9 +5,9 @@ export interface Device {
5
5
  /** Device id. */
6
6
  id?: string | undefined;
7
7
  /** Push transport. */
8
- platform?: string | undefined;
8
+ platform?: Device.Platform | undefined;
9
9
  /** Registration lifecycle. */
10
- status?: string | undefined;
10
+ status?: Device.Status | undefined;
11
11
  /** When the device was first registered. */
12
12
  registered_at?: string | undefined;
13
13
  /** When the registration was last refreshed (last seen). */
@@ -16,6 +16,21 @@ export interface Device {
16
16
  object?: Device.Object_ | undefined;
17
17
  }
18
18
  export declare namespace Device {
19
+ /** Push transport. */
20
+ const Platform: {
21
+ readonly Ios: "ios";
22
+ readonly Android: "android";
23
+ readonly Web: "web";
24
+ };
25
+ type Platform = (typeof Platform)[keyof typeof Platform];
26
+ /** Registration lifecycle. */
27
+ const Status: {
28
+ readonly Active: "active";
29
+ readonly Suspended: "suspended";
30
+ readonly Inactive: "inactive";
31
+ readonly Expired: "expired";
32
+ };
33
+ type Status = (typeof Status)[keyof typeof Status];
19
34
  /** Object type discriminator. */
20
35
  const Object_: {
21
36
  readonly Device: "device";
@@ -4,6 +4,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Device = void 0;
5
5
  var Device;
6
6
  (function (Device) {
7
+ /** Push transport. */
8
+ Device.Platform = {
9
+ Ios: "ios",
10
+ Android: "android",
11
+ Web: "web",
12
+ };
13
+ /** Registration lifecycle. */
14
+ Device.Status = {
15
+ Active: "active",
16
+ Suspended: "suspended",
17
+ Inactive: "inactive",
18
+ Expired: "expired",
19
+ };
7
20
  /** Object type discriminator. */
8
21
  Device.Object_ = {
9
22
  Device: "device",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nizam-os/operator-sdk",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "Nizam Operator API SDK for TypeScript / JavaScript.",
5
5
  "license": "MIT",
6
6
  "private": false,