@nizam-os/customer-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 NizamCustomer.BadRequestError}
42
42
  * @throws {@link NizamCustomer.UnauthorizedError}
43
43
  * @throws {@link NizamCustomer.ForbiddenError}
44
+ * @throws {@link NizamCustomer.ConflictError}
44
45
  * @throws {@link NizamCustomer.ContentTooLargeError}
45
46
  * @throws {@link NizamCustomer.UnprocessableEntityError}
46
47
  * @throws {@link NizamCustomer.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",
@@ -134,6 +134,7 @@ class FilesClient {
134
134
  * @throws {@link NizamCustomer.BadRequestError}
135
135
  * @throws {@link NizamCustomer.UnauthorizedError}
136
136
  * @throws {@link NizamCustomer.ForbiddenError}
137
+ * @throws {@link NizamCustomer.ConflictError}
137
138
  * @throws {@link NizamCustomer.ContentTooLargeError}
138
139
  * @throws {@link NizamCustomer.UnprocessableEntityError}
139
140
  * @throws {@link NizamCustomer.TooManyRequestsError}
@@ -141,6 +142,7 @@ class FilesClient {
141
142
  *
142
143
  * @example
143
144
  * await client.files.initiateFileUpload({
145
+ * "Idempotency-Key": "9f1e6d2a-7c3b-4e5f-8a91-0b2c3d4e5f60",
144
146
  * kind: "profile_picture",
145
147
  * subject_type: "task_attempt",
146
148
  * subject_id: "b3c4d5e6-7f8a-9b0c-1d2e-3f4a5b6c7d8e",
@@ -154,8 +156,9 @@ class FilesClient {
154
156
  return core.HttpResponsePromise.fromPromise(this.__initiateFileUpload(request, requestOptions));
155
157
  }
156
158
  async __initiateFileUpload(request, requestOptions) {
159
+ const { "Idempotency-Key": idempotencyKey, ..._body } = request;
157
160
  const _authRequest = await this._options.authProvider.getAuthRequest();
158
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, requestOptions?.headers);
161
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "Idempotency-Key": idempotencyKey }), requestOptions?.headers);
159
162
  const _response = await core.fetcher({
160
163
  url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
161
164
  (await core.Supplier.get(this._options.environment)) ??
@@ -165,7 +168,7 @@ class FilesClient {
165
168
  contentType: "application/json",
166
169
  queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
167
170
  requestType: "json",
168
- body: request,
171
+ body: _body,
169
172
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
170
173
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
171
174
  abortSignal: requestOptions?.abortSignal,
@@ -183,6 +186,8 @@ class FilesClient {
183
186
  throw new NizamCustomer.UnauthorizedError(_response.error.body, _response.rawResponse);
184
187
  case 403:
185
188
  throw new NizamCustomer.ForbiddenError(_response.error.body, _response.rawResponse);
189
+ case 409:
190
+ throw new NizamCustomer.ConflictError(_response.error.body, _response.rawResponse);
186
191
  case 413:
187
192
  throw new NizamCustomer.ContentTooLargeError(_response.error.body, _response.rawResponse);
188
193
  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). */
@@ -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/customer-sdk",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "Nizam Customer API SDK for TypeScript / JavaScript.",
5
5
  "license": "MIT",
6
6
  "private": false,