@grest-ts/common 0.0.5

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 (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +81 -0
  3. package/dist/src/GGAsyncStorage.d.ts +12 -0
  4. package/dist/src/GGAsyncStorage.d.ts.map +1 -0
  5. package/dist/src/GGAsyncStorage.js +20 -0
  6. package/dist/src/GGAsyncStorage.js.map +1 -0
  7. package/dist/src/GGError.d.ts +32 -0
  8. package/dist/src/GGError.d.ts.map +1 -0
  9. package/dist/src/GGError.js +47 -0
  10. package/dist/src/GGError.js.map +1 -0
  11. package/dist/src/GGExtensionDiscovery.d.ts +54 -0
  12. package/dist/src/GGExtensionDiscovery.d.ts.map +1 -0
  13. package/dist/src/GGExtensionDiscovery.js +281 -0
  14. package/dist/src/GGExtensionDiscovery.js.map +1 -0
  15. package/dist/src/Secret.d.ts +46 -0
  16. package/dist/src/Secret.d.ts.map +1 -0
  17. package/dist/src/Secret.js +68 -0
  18. package/dist/src/Secret.js.map +1 -0
  19. package/dist/src/UnreachableCode.d.ts +5 -0
  20. package/dist/src/UnreachableCode.d.ts.map +1 -0
  21. package/dist/src/UnreachableCode.js +9 -0
  22. package/dist/src/UnreachableCode.js.map +1 -0
  23. package/dist/src/deepClone.d.ts +6 -0
  24. package/dist/src/deepClone.d.ts.map +1 -0
  25. package/dist/src/deepClone.js +38 -0
  26. package/dist/src/deepClone.js.map +1 -0
  27. package/dist/src/deepFreeze.d.ts +6 -0
  28. package/dist/src/deepFreeze.d.ts.map +1 -0
  29. package/dist/src/deepFreeze.js +22 -0
  30. package/dist/src/deepFreeze.js.map +1 -0
  31. package/dist/src/environment.d.ts +14 -0
  32. package/dist/src/environment.d.ts.map +1 -0
  33. package/dist/src/environment.js +18 -0
  34. package/dist/src/environment.js.map +1 -0
  35. package/dist/src/http.d.ts +50 -0
  36. package/dist/src/http.d.ts.map +1 -0
  37. package/dist/src/http.js +50 -0
  38. package/dist/src/http.js.map +1 -0
  39. package/dist/src/index-browser.d.ts +12 -0
  40. package/dist/src/index-browser.d.ts.map +1 -0
  41. package/dist/src/index-browser.js +13 -0
  42. package/dist/src/index-browser.js.map +1 -0
  43. package/dist/src/index-node.d.ts +13 -0
  44. package/dist/src/index-node.d.ts.map +1 -0
  45. package/dist/src/index-node.js +13 -0
  46. package/dist/src/index-node.js.map +1 -0
  47. package/dist/src/sleep.d.ts +2 -0
  48. package/dist/src/sleep.d.ts.map +1 -0
  49. package/dist/src/sleep.js +4 -0
  50. package/dist/src/sleep.js.map +1 -0
  51. package/dist/src/tsconfig.json +17 -0
  52. package/dist/src/types.d.ts +15 -0
  53. package/dist/src/types.d.ts.map +1 -0
  54. package/dist/src/types.js +2 -0
  55. package/dist/src/types.js.map +1 -0
  56. package/dist/src/withTimeout.d.ts +11 -0
  57. package/dist/src/withTimeout.d.ts.map +1 -0
  58. package/dist/src/withTimeout.js +22 -0
  59. package/dist/src/withTimeout.js.map +1 -0
  60. package/dist/tsconfig.publish.tsbuildinfo +1 -0
  61. package/package.json +58 -0
  62. package/src/GGAsyncStorage.ts +27 -0
  63. package/src/GGError.ts +74 -0
  64. package/src/GGExtensionDiscovery.ts +314 -0
  65. package/src/Secret.ts +76 -0
  66. package/src/UnreachableCode.ts +9 -0
  67. package/src/deepClone.ts +43 -0
  68. package/src/deepFreeze.ts +21 -0
  69. package/src/environment.ts +22 -0
  70. package/src/http.ts +52 -0
  71. package/src/index-browser.ts +12 -0
  72. package/src/index-node.ts +12 -0
  73. package/src/sleep.ts +3 -0
  74. package/src/tsconfig.json +17 -0
  75. package/src/types.ts +16 -0
  76. package/src/withTimeout.ts +20 -0
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Secret - A wrapper for sensitive values that prevents accidental logging.
3
+ *
4
+ * Secrets are automatically redacted when:
5
+ * - Converted to string (toString)
6
+ * - Serialized to JSON (toJSON)
7
+ * - Logged with console.log or util.inspect
8
+ *
9
+ * To access the actual value, you must explicitly call unwrap().
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const dbPassword = new Secret('super-secret-password');
14
+ *
15
+ * console.log(dbPassword); // "[REDACTED]"
16
+ * console.log(JSON.stringify(dbPassword)); // "[REDACTED]"
17
+ *
18
+ * // Explicit unwrap required to get value
19
+ * const password = dbPassword.unwrap();
20
+ * ```
21
+ */
22
+ export class Secret {
23
+ #value;
24
+ constructor(value) {
25
+ this.#value = value;
26
+ }
27
+ /**
28
+ * Get the actual secret value.
29
+ * Use with care - avoid logging the result.
30
+ */
31
+ unwrap() {
32
+ return this.#value;
33
+ }
34
+ /**
35
+ * Check if the secret has a non-empty value.
36
+ */
37
+ hasValue() {
38
+ return this.#value.length > 0;
39
+ }
40
+ /**
41
+ * Compare with another secret without exposing either value.
42
+ */
43
+ equals(other) {
44
+ return this.#value === other.#value;
45
+ }
46
+ // Prevent accidental logging/serialization
47
+ toString() {
48
+ return '[REDACTED]';
49
+ }
50
+ toJSON() {
51
+ return '[REDACTED]';
52
+ }
53
+ // Node.js console.log and util.inspect use this
54
+ [Symbol.for('nodejs.util.inspect.custom')]() {
55
+ return '[REDACTED]';
56
+ }
57
+ // Prevent valueOf from leaking
58
+ valueOf() {
59
+ return '[REDACTED]';
60
+ }
61
+ }
62
+ /**
63
+ * Type guard to check if a value is a Secret.
64
+ */
65
+ export function isSecret(value) {
66
+ return value instanceof Secret;
67
+ }
68
+ //# sourceMappingURL=Secret.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Secret.js","sourceRoot":"","sources":["../../src/Secret.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,MAAM;IACf,MAAM,CAAS;IACf,YAAY,KAAa;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,MAAM;QACF,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,QAAQ;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAa;QAChB,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,CAAC;IACxC,CAAC;IAED,2CAA2C;IAE3C,QAAQ;QACJ,OAAO,YAAY,CAAC;IACxB,CAAC;IAED,MAAM;QACF,OAAO,YAAY,CAAC;IACxB,CAAC;IAED,gDAAgD;IAChD,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACtC,OAAO,YAAY,CAAC;IACxB,CAAC;IAED,+BAA+B;IAC/B,OAAO;QACH,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,MAAM,CAAC;AACnC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare class UnreachableCode {
2
+ static never<T>(input: never, defaultValue?: T): T;
3
+ static throwNever<T>(input: never, defaultValue?: Error): T;
4
+ }
5
+ //# sourceMappingURL=UnreachableCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnreachableCode.d.ts","sourceRoot":"","sources":["../../src/UnreachableCode.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAe;WACV,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC;WAI3C,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,EAAE,KAAK,GAAG,CAAC;CAGrE"}
@@ -0,0 +1,9 @@
1
+ export class UnreachableCode {
2
+ static never(input, defaultValue) {
3
+ return defaultValue;
4
+ }
5
+ static throwNever(input, defaultValue) {
6
+ throw defaultValue;
7
+ }
8
+ }
9
+ //# sourceMappingURL=UnreachableCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnreachableCode.js","sourceRoot":"","sources":["../../src/UnreachableCode.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;IACjB,MAAM,CAAC,KAAK,CAAI,KAAY,EAAE,YAAgB;QACjD,OAAO,YAAY,CAAC;IACxB,CAAC;IAEM,MAAM,CAAC,UAAU,CAAI,KAAY,EAAE,YAAoB;QAC1D,MAAM,YAAY,CAAC;IACvB,CAAC;CACJ"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Recursively clones an object and all its nested properties.
3
+ * Handles: primitives, arrays, plain objects, Date, Map, Set.
4
+ */
5
+ export declare function deepClone<T>(obj: T): T;
6
+ //# sourceMappingURL=deepClone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepClone.d.ts","sourceRoot":"","sources":["../../src/deepClone.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAsCtC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Recursively clones an object and all its nested properties.
3
+ * Handles: primitives, arrays, plain objects, Date, Map, Set.
4
+ */
5
+ export function deepClone(obj) {
6
+ if (obj === null || obj === undefined) {
7
+ return obj;
8
+ }
9
+ if (typeof obj !== 'object') {
10
+ return obj;
11
+ }
12
+ if (obj instanceof Date) {
13
+ return new Date(obj.getTime());
14
+ }
15
+ if (obj instanceof Map) {
16
+ const clonedMap = new Map();
17
+ for (const [key, value] of obj) {
18
+ clonedMap.set(deepClone(key), deepClone(value));
19
+ }
20
+ return clonedMap;
21
+ }
22
+ if (obj instanceof Set) {
23
+ const clonedSet = new Set();
24
+ for (const value of obj) {
25
+ clonedSet.add(deepClone(value));
26
+ }
27
+ return clonedSet;
28
+ }
29
+ if (Array.isArray(obj)) {
30
+ return obj.map(item => deepClone(item));
31
+ }
32
+ const clonedObj = {};
33
+ for (const key of Object.keys(obj)) {
34
+ clonedObj[key] = deepClone(obj[key]);
35
+ }
36
+ return clonedObj;
37
+ }
38
+ //# sourceMappingURL=deepClone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepClone.js","sourceRoot":"","sources":["../../src/deepClone.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAI,GAAM;IAC/B,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,GAAG,CAAC;IACf,CAAC;IAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,GAAG,CAAC;IACf,CAAC;IAED,IAAI,GAAG,YAAY,IAAI,EAAE,CAAC;QACtB,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAM,CAAC;IACxC,CAAC;IAED,IAAI,GAAG,YAAY,GAAG,EAAE,CAAC;QACrB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;YAC7B,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,SAAc,CAAC;IAC1B,CAAC;IAED,IAAI,GAAG,YAAY,GAAG,EAAE,CAAC;QACrB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC;YACtB,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,SAAc,CAAC;IAC1B,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAM,CAAC;IACjD,CAAC;IAED,MAAM,SAAS,GAA4B,EAAE,CAAC;IAC9C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACjC,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,SAAc,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Recursively freezes an object and all its nested properties.
3
+ * Used to create immutable objects.
4
+ */
5
+ export declare function deepFreeze<T>(o: T): T;
6
+ //# sourceMappingURL=deepFreeze.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepFreeze.d.ts","sourceRoot":"","sources":["../../src/deepFreeze.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAgBrC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Recursively freezes an object and all its nested properties.
3
+ * Used to create immutable objects.
4
+ */
5
+ export function deepFreeze(o) {
6
+ if (o === undefined) {
7
+ return o;
8
+ }
9
+ Object.freeze(o);
10
+ Object.getOwnPropertyNames(o).forEach(function (prop) {
11
+ if (prop === "renderers") {
12
+ return;
13
+ }
14
+ if (o[prop] !== null
15
+ && (typeof o[prop] === "object" || typeof o[prop] === "function")
16
+ && !Object.isFrozen(o[prop])) {
17
+ deepFreeze(o[prop]);
18
+ }
19
+ });
20
+ return o;
21
+ }
22
+ //# sourceMappingURL=deepFreeze.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepFreeze.js","sourceRoot":"","sources":["../../src/deepFreeze.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAI,CAAI;IAC9B,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QAClB,OAAO,CAAC,CAAC;IACb,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACjB,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI;QAChD,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;YACvB,OAAO;QACX,CAAC;QACD,IAAK,CAAS,CAAC,IAAI,CAAC,KAAK,IAAI;eACtB,CAAC,OAAQ,CAAS,CAAC,IAAI,CAAC,KAAK,QAAQ,IAAI,OAAQ,CAAS,CAAC,IAAI,CAAC,KAAK,UAAU,CAAC;eAChF,CAAC,MAAM,CAAC,QAAQ,CAAE,CAAS,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACxC,UAAU,CAAE,CAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,CAAC;AACb,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Environment detection utilities that work without DOM lib
3
+ * Uses type assertions to avoid TypeScript errors in Node-only contexts
4
+ */
5
+ /**
6
+ * Check if code is running in a browser environment
7
+ * Works in both Node.js and browser contexts without requiring DOM lib
8
+ */
9
+ export declare function isBrowser(): boolean;
10
+ /**
11
+ * Check if code is running in a Node.js environment
12
+ */
13
+ export declare function isNode(): boolean;
14
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;GAGG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAEhC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Environment detection utilities that work without DOM lib
3
+ * Uses type assertions to avoid TypeScript errors in Node-only contexts
4
+ */
5
+ /**
6
+ * Check if code is running in a browser environment
7
+ * Works in both Node.js and browser contexts without requiring DOM lib
8
+ */
9
+ export function isBrowser() {
10
+ return typeof window !== 'undefined' && typeof window.document !== 'undefined';
11
+ }
12
+ /**
13
+ * Check if code is running in a Node.js environment
14
+ */
15
+ export function isNode() {
16
+ return !isBrowser();
17
+ }
18
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;GAGG;AACH,MAAM,UAAU,SAAS;IACrB,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAA;AAClF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM;IAClB,OAAO,CAAC,SAAS,EAAE,CAAA;AACvB,CAAC"}
@@ -0,0 +1,50 @@
1
+ export declare enum HttpStatusCode {
2
+ OK200 = 200,
3
+ /**
4
+ * Completely fails to handle the request
5
+ */
6
+ BadRequest400 = 400,
7
+ /**
8
+ * User must send auth headers or in other ways be "logged in".
9
+ */
10
+ Unauthorized401 = 401,
11
+ /**
12
+ * User does not have access to resource
13
+ */
14
+ Forbidden403 = 403,
15
+ /**
16
+ * Entity not found
17
+ */
18
+ NotFound404 = 404,
19
+ /**
20
+ * Duplicate entity somewhere
21
+ */
22
+ Exists409 = 409,
23
+ /**
24
+ * These are validation errors - automatic or manual.
25
+ */
26
+ ValidationError422 = 422,
27
+ /**
28
+ * Method not allowed on this resource.
29
+ */
30
+ MethodNotAllowed405 = 405,
31
+ /**
32
+ * Generic "something went wrong".
33
+ */
34
+ InternalServerError500 = 500,
35
+ /**
36
+ * Bad Gateway - proxy/gateway received invalid response.
37
+ */
38
+ BadGateway502 = 502,
39
+ /**
40
+ * Server is shutting down and is not able to handle the request.
41
+ */
42
+ ServerTemporarilyNotAvailable503 = 503,
43
+ /**
44
+ * Non standard HTTP error! This is used in the test framework in case request failes because of some testing check.
45
+ * Request itself maybe succeeded, but some check caused it to still fail. This never comes up in production, only in automated tests.
46
+ */
47
+ TestingError = 800
48
+ }
49
+ export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
50
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACtB,KAAK,MAAM;IACX;;OAEG;IACH,aAAa,MAAM;IACnB;;OAEG;IACH,eAAe,MAAM;IACrB;;OAEG;IACH,YAAY,MAAM;IAClB;;OAEG;IACH,WAAW,MAAM;IACjB;;OAEG;IACH,SAAS,MAAM;IACf;;OAEG;IACH,kBAAkB,MAAM;IACxB;;OAEG;IACH,mBAAmB,MAAM;IACzB;;OAEG;IACH,sBAAsB,MAAM;IAC5B;;OAEG;IACH,aAAa,MAAM;IACnB;;OAEG;IACH,gCAAgC,MAAM;IAGtC;;;OAGG;IACH,YAAY,MAAM;CACrB;AAED,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC"}
@@ -0,0 +1,50 @@
1
+ export var HttpStatusCode;
2
+ (function (HttpStatusCode) {
3
+ HttpStatusCode[HttpStatusCode["OK200"] = 200] = "OK200";
4
+ /**
5
+ * Completely fails to handle the request
6
+ */
7
+ HttpStatusCode[HttpStatusCode["BadRequest400"] = 400] = "BadRequest400";
8
+ /**
9
+ * User must send auth headers or in other ways be "logged in".
10
+ */
11
+ HttpStatusCode[HttpStatusCode["Unauthorized401"] = 401] = "Unauthorized401";
12
+ /**
13
+ * User does not have access to resource
14
+ */
15
+ HttpStatusCode[HttpStatusCode["Forbidden403"] = 403] = "Forbidden403";
16
+ /**
17
+ * Entity not found
18
+ */
19
+ HttpStatusCode[HttpStatusCode["NotFound404"] = 404] = "NotFound404";
20
+ /**
21
+ * Duplicate entity somewhere
22
+ */
23
+ HttpStatusCode[HttpStatusCode["Exists409"] = 409] = "Exists409";
24
+ /**
25
+ * These are validation errors - automatic or manual.
26
+ */
27
+ HttpStatusCode[HttpStatusCode["ValidationError422"] = 422] = "ValidationError422";
28
+ /**
29
+ * Method not allowed on this resource.
30
+ */
31
+ HttpStatusCode[HttpStatusCode["MethodNotAllowed405"] = 405] = "MethodNotAllowed405";
32
+ /**
33
+ * Generic "something went wrong".
34
+ */
35
+ HttpStatusCode[HttpStatusCode["InternalServerError500"] = 500] = "InternalServerError500";
36
+ /**
37
+ * Bad Gateway - proxy/gateway received invalid response.
38
+ */
39
+ HttpStatusCode[HttpStatusCode["BadGateway502"] = 502] = "BadGateway502";
40
+ /**
41
+ * Server is shutting down and is not able to handle the request.
42
+ */
43
+ HttpStatusCode[HttpStatusCode["ServerTemporarilyNotAvailable503"] = 503] = "ServerTemporarilyNotAvailable503";
44
+ /**
45
+ * Non standard HTTP error! This is used in the test framework in case request failes because of some testing check.
46
+ * Request itself maybe succeeded, but some check caused it to still fail. This never comes up in production, only in automated tests.
47
+ */
48
+ HttpStatusCode[HttpStatusCode["TestingError"] = 800] = "TestingError";
49
+ })(HttpStatusCode || (HttpStatusCode = {}));
50
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,cAiDX;AAjDD,WAAY,cAAc;IACtB,uDAAW,CAAA;IACX;;OAEG;IACH,uEAAmB,CAAA;IACnB;;OAEG;IACH,2EAAqB,CAAA;IACrB;;OAEG;IACH,qEAAkB,CAAA;IAClB;;OAEG;IACH,mEAAiB,CAAA;IACjB;;OAEG;IACH,+DAAe,CAAA;IACf;;OAEG;IACH,iFAAwB,CAAA;IACxB;;OAEG;IACH,mFAAyB,CAAA;IACzB;;OAEG;IACH,yFAA4B,CAAA;IAC5B;;OAEG;IACH,uEAAmB,CAAA;IACnB;;OAEG;IACH,6GAAsC,CAAA;IAGtC;;;OAGG;IACH,qEAAkB,CAAA;AACtB,CAAC,EAjDW,cAAc,KAAd,cAAc,QAiDzB"}
@@ -0,0 +1,12 @@
1
+ export * from './deepFreeze';
2
+ export * from './deepClone';
3
+ export * from './withTimeout';
4
+ export * from './GGError';
5
+ export * from './UnreachableCode';
6
+ export * from './types';
7
+ export * from './http';
8
+ export * from './Secret';
9
+ export * from "./sleep";
10
+ export * from "./environment";
11
+ export * from "./GGAsyncStorage";
12
+ //# sourceMappingURL=index-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-browser.d.ts","sourceRoot":"","sources":["../../src/index-browser.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,13 @@
1
+ export * from './deepFreeze.js';
2
+ export * from './deepClone.js';
3
+ export * from './withTimeout.js';
4
+ export * from './GGError.js';
5
+ export * from './UnreachableCode.js';
6
+ export * from './types.js';
7
+ export * from './http.js';
8
+ export * from './Secret.js';
9
+ export * from "./sleep.js";
10
+ export * from "./environment.js";
11
+ export * from "./GGAsyncStorage.js";
12
+ // GGExtensionDiscovery excluded — uses Node.js fs/path/url
13
+ //# sourceMappingURL=index-browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-browser.js","sourceRoot":"","sources":["../../src/index-browser.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,2DAA2D"}
@@ -0,0 +1,13 @@
1
+ export * from './deepFreeze';
2
+ export * from './deepClone';
3
+ export * from './withTimeout';
4
+ export * from './GGError';
5
+ export * from './UnreachableCode';
6
+ export * from './types';
7
+ export * from './http';
8
+ export * from './Secret';
9
+ export * from "./sleep";
10
+ export * from "./environment";
11
+ export * from "./GGAsyncStorage";
12
+ export * from "./GGExtensionDiscovery";
13
+ //# sourceMappingURL=index-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-node.d.ts","sourceRoot":"","sources":["../../src/index-node.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA"}
@@ -0,0 +1,13 @@
1
+ export * from './deepFreeze.js';
2
+ export * from './deepClone.js';
3
+ export * from './withTimeout.js';
4
+ export * from './GGError.js';
5
+ export * from './UnreachableCode.js';
6
+ export * from './types.js';
7
+ export * from './http.js';
8
+ export * from './Secret.js';
9
+ export * from "./sleep.js";
10
+ export * from "./environment.js";
11
+ export * from "./GGAsyncStorage.js";
12
+ export * from "./GGExtensionDiscovery.js";
13
+ //# sourceMappingURL=index-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-node.js","sourceRoot":"","sources":["../../src/index-node.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function sleep(ms: number, _reason?: string): Promise<void>;
2
+ //# sourceMappingURL=sleep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/sleep.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjE"}
@@ -0,0 +1,4 @@
1
+ export function sleep(ms, _reason) {
2
+ return new Promise(resolve => setTimeout(resolve, ms));
3
+ }
4
+ //# sourceMappingURL=sleep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/sleep.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CAAC,EAAU,EAAE,OAAgB;IAC9C,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,17 @@
1
+ {
2
+ "//": "THIS FILE IS GENERATED - DO NOT EDIT",
3
+ "extends": "../../../tsconfig.base.json",
4
+ "compilerOptions": {
5
+ "rootDir": ".",
6
+ "lib": [
7
+ "ES2022",
8
+ "DOM"
9
+ ],
10
+ "types": [
11
+ "node"
12
+ ]
13
+ },
14
+ "include": [
15
+ "**/*"
16
+ ]
17
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Recursively makes all properties of an object optional.
3
+ * Useful for partial matching in tests and validation.
4
+ */
5
+ export type DeepPartial<T> = T extends object ? T extends Array<infer U> ? Array<DeepPartial<U>> : {
6
+ [P in keyof T]?: DeepPartial<T[P]>;
7
+ } : T;
8
+ export type ConstructorOf<T> = new (...args: any[]) => T;
9
+ /**
10
+ * Returns the instance of a class. T would be the class reference.
11
+ */
12
+ export type InstanceOf<T> = T extends {
13
+ new (...args: any[]): infer S;
14
+ } ? S : undefined;
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GACvC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACpB,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACrB;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC1C,CAAC,CAAA;AAEP,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,KAAI,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,SAAS,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Wraps a promise with a timeout. If the promise doesn't resolve/reject within
3
+ * the specified timeout, the returned promise will reject with an error.
4
+ *
5
+ * @param promise - The promise to wrap
6
+ * @param timeoutMs - Timeout in milliseconds
7
+ * @param errorMessage - Error message to use when timeout occurs
8
+ * @returns A promise that resolves/rejects with the original promise or times out
9
+ */
10
+ export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, errorMessage: string): Promise<T>;
11
+ //# sourceMappingURL=withTimeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withTimeout.d.ts","sourceRoot":"","sources":["../../src/withTimeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAU7G"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Wraps a promise with a timeout. If the promise doesn't resolve/reject within
3
+ * the specified timeout, the returned promise will reject with an error.
4
+ *
5
+ * @param promise - The promise to wrap
6
+ * @param timeoutMs - Timeout in milliseconds
7
+ * @param errorMessage - Error message to use when timeout occurs
8
+ * @returns A promise that resolves/rejects with the original promise or times out
9
+ */
10
+ export async function withTimeout(promise, timeoutMs, errorMessage) {
11
+ let timeoutId;
12
+ const timeoutPromise = new Promise((_, reject) => {
13
+ timeoutId = setTimeout(() => reject(new Error(errorMessage)), timeoutMs);
14
+ });
15
+ try {
16
+ return await Promise.race([promise, timeoutPromise]);
17
+ }
18
+ finally {
19
+ clearTimeout(timeoutId);
20
+ }
21
+ }
22
+ //# sourceMappingURL=withTimeout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withTimeout.js","sourceRoot":"","sources":["../../src/withTimeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAI,OAAmB,EAAE,SAAiB,EAAE,YAAoB;IAC7F,IAAI,SAAc,CAAC;IACnB,MAAM,cAAc,GAAG,IAAI,OAAO,CAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QACpD,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IACH,IAAI,CAAC;QACD,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;IACzD,CAAC;YAAS,CAAC;QACP,YAAY,CAAC,SAAU,CAAC,CAAC;IAC7B,CAAC;AACL,CAAC"}