@origincloud/core 0.6.0 → 0.8.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/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +20 -0
- package/dist/errors.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +1 -1
- package/src/errors.ts +20 -0
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Credentials, type FetchLike, type TokenSource } from "./credentials.js";
|
|
2
2
|
import { Service } from "./transport.js";
|
|
3
3
|
/** This SDK's version, sent in the User-Agent header from Node. */
|
|
4
|
-
export declare const VERSION = "0.
|
|
4
|
+
export declare const VERSION = "0.8.0";
|
|
5
5
|
/** How a {@link Client} is configured. */
|
|
6
6
|
export interface ClientOptions {
|
|
7
7
|
/**
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toCredentials } from "./credentials.js";
|
|
2
2
|
import { Service } from "./transport.js";
|
|
3
3
|
/** This SDK's version, sent in the User-Agent header from Node. */
|
|
4
|
-
export const VERSION = "0.
|
|
4
|
+
export const VERSION = "0.8.0";
|
|
5
5
|
const DEFAULT_MAX_ATTEMPTS = 5;
|
|
6
6
|
/** The services that answer only at their regionless host. */
|
|
7
7
|
const GLOBAL_SERVICES = new Set(["iam", "resourcemanager", "location"]);
|
package/dist/errors.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface OriginCloudErrorFields {
|
|
|
9
9
|
httpStatus: number;
|
|
10
10
|
status: string;
|
|
11
11
|
reason: string;
|
|
12
|
+
metadata: Record<string, string>;
|
|
12
13
|
message: string;
|
|
13
14
|
requestId: string;
|
|
14
15
|
fieldViolations: FieldViolation[];
|
|
@@ -29,6 +30,13 @@ export declare class OriginCloudError extends Error {
|
|
|
29
30
|
* branch on.
|
|
30
31
|
*/
|
|
31
32
|
readonly reason: string;
|
|
33
|
+
/**
|
|
34
|
+
* What the error is about, by key, as the API names it alongside
|
|
35
|
+
* {@link OriginCloudError.reason}: such as `serviceAccount`, the name of
|
|
36
|
+
* the service account a `CONFLICT` is about. Empty when the API names
|
|
37
|
+
* nothing.
|
|
38
|
+
*/
|
|
39
|
+
readonly metadata: Readonly<Record<string, string>>;
|
|
32
40
|
/** Identifies the request to Origin Cloud's support. */
|
|
33
41
|
readonly requestId: string;
|
|
34
42
|
/** The request fields that were refused, by their JSON path. */
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,mDAAmD;AACnD,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,8DAA8D;IAC9D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,eAAe,EAAE,SAAS,cAAc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QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;gBAGhB,MAAM,EAAE,OAAO,CAAC,sBAAsB,CAAC;IAuBnD;;;OAGG;IACM,QAAQ,IAAI,MAAM;IAI3B,OAAO,CAAC,OAAO;CAMhB;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAE7C;AA2DD,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGpD;AA+BD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,CA0BpF;AAED,iEAAiE;AACjE,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,gBAAgB,CAajE"}
|
package/dist/errors.js
CHANGED
|
@@ -12,6 +12,13 @@ export class OriginCloudError extends Error {
|
|
|
12
12
|
* branch on.
|
|
13
13
|
*/
|
|
14
14
|
reason;
|
|
15
|
+
/**
|
|
16
|
+
* What the error is about, by key, as the API names it alongside
|
|
17
|
+
* {@link OriginCloudError.reason}: such as `serviceAccount`, the name of
|
|
18
|
+
* the service account a `CONFLICT` is about. Empty when the API names
|
|
19
|
+
* nothing.
|
|
20
|
+
*/
|
|
21
|
+
metadata;
|
|
15
22
|
/** Identifies the request to Origin Cloud's support. */
|
|
16
23
|
requestId;
|
|
17
24
|
/** The request fields that were refused, by their JSON path. */
|
|
@@ -30,6 +37,7 @@ export class OriginCloudError extends Error {
|
|
|
30
37
|
this.httpStatus = fields.httpStatus ?? 0;
|
|
31
38
|
this.status = fields.status ?? "";
|
|
32
39
|
this.reason = fields.reason ?? "";
|
|
40
|
+
this.metadata = fields.metadata ?? {};
|
|
33
41
|
this.requestId = fields.requestId ?? "";
|
|
34
42
|
this.fieldViolations = fields.fieldViolations ?? [];
|
|
35
43
|
this.retryDelayMs = fields.retryDelayMs ?? 0;
|
|
@@ -110,6 +118,17 @@ function isRecord(value) {
|
|
|
110
118
|
function str(value) {
|
|
111
119
|
return typeof value === "string" ? value : "";
|
|
112
120
|
}
|
|
121
|
+
/** The string values of a JSON map; empty when it isn't one. */
|
|
122
|
+
function strings(value) {
|
|
123
|
+
const out = {};
|
|
124
|
+
if (!isRecord(value))
|
|
125
|
+
return out;
|
|
126
|
+
for (const [key, v] of Object.entries(value)) {
|
|
127
|
+
if (typeof v === "string")
|
|
128
|
+
out[key] = v;
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
113
132
|
/** A JSON duration, such as `1.5s`, in milliseconds; 0 when it isn't one. */
|
|
114
133
|
export function parseDuration(value) {
|
|
115
134
|
const match = typeof value === "string" ? /^(\d+(?:\.\d+)?)s$/.exec(value) : null;
|
|
@@ -125,6 +144,7 @@ function readDetails(details, into) {
|
|
|
125
144
|
switch (detail["@type"]) {
|
|
126
145
|
case TYPE_ERROR_INFO:
|
|
127
146
|
into.reason = str(detail["reason"]);
|
|
147
|
+
into.metadata = strings(detail["metadata"]);
|
|
128
148
|
break;
|
|
129
149
|
case TYPE_REQUEST_INFO:
|
|
130
150
|
into.requestId = str(detail["requestId"]);
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,8DAA8D;IACrD,UAAU,CAAS;IAC5B,4EAA4E;IACnE,MAAM,CAAS;IACxB;;;OAGG;IACM,MAAM,CAAS;IACxB;;;;;OAKG;IACM,QAAQ,CAAmC;IACpD,wDAAwD;IAC/C,SAAS,CAAS;IAC3B,gEAAgE;IACvD,eAAe,CAA4B;IACpD;;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MAAM,CAAC,CAAC;AACtC,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,eAAe,CAAC,MAAe;IAC7C,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACzC,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAoC;QAC9C,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,QAAQ,IAAI,EAAE;QACrC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;KAC3B,CAAC;IACF,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;IAClC,sEAAsE;IACtE,aAAa;IACb,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC;IACxB,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@origincloud/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "What every Origin Cloud SDK service package shares: credentials, endpoints, retries, errors, long-running operations and read-your-writes.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/origincloudhq/sdk-typescript#readme",
|
package/src/client.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type Credentials, type FetchLike, type TokenSource, toCredentials } fro
|
|
|
2
2
|
import { Service } from "./transport.js";
|
|
3
3
|
|
|
4
4
|
/** This SDK's version, sent in the User-Agent header from Node. */
|
|
5
|
-
export const VERSION = "0.
|
|
5
|
+
export const VERSION = "0.8.0";
|
|
6
6
|
|
|
7
7
|
const DEFAULT_MAX_ATTEMPTS = 5;
|
|
8
8
|
|
package/src/errors.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface OriginCloudErrorFields {
|
|
|
10
10
|
httpStatus: number;
|
|
11
11
|
status: string;
|
|
12
12
|
reason: string;
|
|
13
|
+
metadata: Record<string, string>;
|
|
13
14
|
message: string;
|
|
14
15
|
requestId: string;
|
|
15
16
|
fieldViolations: FieldViolation[];
|
|
@@ -31,6 +32,13 @@ export class OriginCloudError extends Error {
|
|
|
31
32
|
* branch on.
|
|
32
33
|
*/
|
|
33
34
|
readonly reason: string;
|
|
35
|
+
/**
|
|
36
|
+
* What the error is about, by key, as the API names it alongside
|
|
37
|
+
* {@link OriginCloudError.reason}: such as `serviceAccount`, the name of
|
|
38
|
+
* the service account a `CONFLICT` is about. Empty when the API names
|
|
39
|
+
* nothing.
|
|
40
|
+
*/
|
|
41
|
+
readonly metadata: Readonly<Record<string, string>>;
|
|
34
42
|
/** Identifies the request to Origin Cloud's support. */
|
|
35
43
|
readonly requestId: string;
|
|
36
44
|
/** The request fields that were refused, by their JSON path. */
|
|
@@ -50,6 +58,7 @@ export class OriginCloudError extends Error {
|
|
|
50
58
|
this.httpStatus = fields.httpStatus ?? 0;
|
|
51
59
|
this.status = fields.status ?? "";
|
|
52
60
|
this.reason = fields.reason ?? "";
|
|
61
|
+
this.metadata = fields.metadata ?? {};
|
|
53
62
|
this.requestId = fields.requestId ?? "";
|
|
54
63
|
this.fieldViolations = fields.fieldViolations ?? [];
|
|
55
64
|
this.retryDelayMs = fields.retryDelayMs ?? 0;
|
|
@@ -137,6 +146,16 @@ function str(value: unknown): string {
|
|
|
137
146
|
return typeof value === "string" ? value : "";
|
|
138
147
|
}
|
|
139
148
|
|
|
149
|
+
/** The string values of a JSON map; empty when it isn't one. */
|
|
150
|
+
function strings(value: unknown): Record<string, string> {
|
|
151
|
+
const out: Record<string, string> = {};
|
|
152
|
+
if (!isRecord(value)) return out;
|
|
153
|
+
for (const [key, v] of Object.entries(value)) {
|
|
154
|
+
if (typeof v === "string") out[key] = v;
|
|
155
|
+
}
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
|
|
140
159
|
/** A JSON duration, such as `1.5s`, in milliseconds; 0 when it isn't one. */
|
|
141
160
|
export function parseDuration(value: unknown): number {
|
|
142
161
|
const match = typeof value === "string" ? /^(\d+(?:\.\d+)?)s$/.exec(value) : null;
|
|
@@ -151,6 +170,7 @@ function readDetails(details: unknown, into: Partial<OriginCloudErrorFields>): v
|
|
|
151
170
|
switch (detail["@type"]) {
|
|
152
171
|
case TYPE_ERROR_INFO:
|
|
153
172
|
into.reason = str(detail["reason"]);
|
|
173
|
+
into.metadata = strings(detail["metadata"]);
|
|
154
174
|
break;
|
|
155
175
|
case TYPE_REQUEST_INFO:
|
|
156
176
|
into.requestId = str(detail["requestId"]);
|