@cravery/types 0.0.6 → 0.0.8
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/common/currency.d.ts +2 -1
- package/dist/common/currency.d.ts.map +1 -1
- package/dist/common/currency.js +9 -0
- package/dist/common/currency.js.map +1 -1
- package/dist/common/index.d.ts +1 -3
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +1 -3
- package/dist/common/index.js.map +1 -1
- package/dist/common/meal_type.d.ts +1 -1
- package/dist/common/meal_type.d.ts.map +1 -1
- package/dist/common/meal_type.js +3 -1
- package/dist/common/meal_type.js.map +1 -1
- package/dist/common/measurement.d.ts +3 -0
- package/dist/common/measurement.d.ts.map +1 -0
- package/dist/common/measurement.js +5 -0
- package/dist/common/measurement.js.map +1 -0
- package/dist/common/temperature.d.ts +2 -1
- package/dist/common/temperature.d.ts.map +1 -1
- package/dist/common/temperature.js +2 -0
- package/dist/common/temperature.js.map +1 -1
- package/dist/common/unit.d.ts +1 -1
- package/dist/common/unit.d.ts.map +1 -1
- package/dist/common/unit.js +1 -0
- package/dist/common/unit.js.map +1 -1
- package/dist/core/entity.d.ts +6 -4
- package/dist/core/entity.d.ts.map +1 -1
- package/dist/core/entity.js +8 -0
- package/dist/core/entity.js.map +1 -1
- package/dist/core/errors.d.ts +65 -25
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +114 -57
- package/dist/core/errors.js.map +1 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +0 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/locale.d.ts +3 -0
- package/dist/core/locale.d.ts.map +1 -1
- package/dist/core/timestamp.d.ts +1 -4
- package/dist/core/timestamp.d.ts.map +1 -1
- package/dist/equipment/entity.d.ts +4 -9
- package/dist/equipment/entity.d.ts.map +1 -1
- package/dist/equipment/user.d.ts +4 -5
- package/dist/equipment/user.d.ts.map +1 -1
- package/dist/feed/recipe.d.ts +3 -3
- package/dist/feed/recipe.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/ingredients/entity.d.ts +4 -9
- package/dist/ingredients/entity.d.ts.map +1 -1
- package/dist/ingredients/user.d.ts +4 -5
- package/dist/ingredients/user.d.ts.map +1 -1
- package/dist/limits/limits.d.ts +1 -1
- package/dist/limits/limits.d.ts.map +1 -1
- package/dist/limits/usage.d.ts +7 -2
- package/dist/limits/usage.d.ts.map +1 -1
- package/dist/recipes/index.d.ts +5 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +5 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/recipes/meta.d.ts +0 -2
- package/dist/recipes/meta.d.ts.map +1 -1
- package/dist/recipes/recipe.d.ts +0 -2
- package/dist/recipes/recipe.d.ts.map +1 -1
- package/dist/recipes/request.d.ts +19 -0
- package/dist/recipes/request.d.ts.map +1 -0
- package/dist/recipes/request.js +10 -0
- package/dist/recipes/request.js.map +1 -0
- package/dist/recipes/stats.d.ts +2 -1
- package/dist/recipes/stats.d.ts.map +1 -1
- package/dist/recipes/user.d.ts +10 -0
- package/dist/recipes/user.d.ts.map +1 -0
- package/dist/recipes/user.js +3 -0
- package/dist/recipes/user.js.map +1 -0
- package/dist/reports/report.d.ts +0 -2
- package/dist/reports/report.d.ts.map +1 -1
- package/dist/settings/settings.d.ts +1 -0
- package/dist/settings/settings.d.ts.map +1 -1
- package/dist/shopping/equipment.d.ts +6 -1
- package/dist/shopping/equipment.d.ts.map +1 -1
- package/dist/shopping/ingredient.d.ts +10 -3
- package/dist/shopping/ingredient.d.ts.map +1 -1
- package/dist/subscription/billing.d.ts +3 -0
- package/dist/subscription/billing.d.ts.map +1 -0
- package/dist/subscription/billing.js +5 -0
- package/dist/subscription/billing.js.map +1 -0
- package/dist/subscription/index.d.ts +10 -0
- package/dist/subscription/index.d.ts.map +1 -0
- package/dist/subscription/index.js +26 -0
- package/dist/subscription/index.js.map +1 -0
- package/dist/subscription/member.d.ts +10 -0
- package/dist/subscription/member.d.ts.map +1 -0
- package/dist/subscription/member.js +3 -0
- package/dist/subscription/member.js.map +1 -0
- package/dist/subscription/member_status.d.ts +3 -0
- package/dist/subscription/member_status.d.ts.map +1 -0
- package/dist/subscription/member_status.js +10 -0
- package/dist/subscription/member_status.js.map +1 -0
- package/dist/subscription/role.d.ts +3 -0
- package/dist/subscription/role.d.ts.map +1 -0
- package/dist/subscription/role.js +5 -0
- package/dist/subscription/role.js.map +1 -0
- package/dist/subscription/sharing.d.ts +6 -0
- package/dist/subscription/sharing.d.ts.map +1 -0
- package/dist/subscription/sharing.js +3 -0
- package/dist/subscription/sharing.js.map +1 -0
- package/dist/subscription/status.d.ts +3 -0
- package/dist/subscription/status.d.ts.map +1 -0
- package/dist/subscription/status.js +14 -0
- package/dist/subscription/status.js.map +1 -0
- package/dist/subscription/store.d.ts +3 -0
- package/dist/subscription/store.d.ts.map +1 -0
- package/dist/subscription/store.js +10 -0
- package/dist/subscription/store.js.map +1 -0
- package/dist/subscription/subscription.d.ts +24 -0
- package/dist/subscription/subscription.d.ts.map +1 -0
- package/dist/subscription/subscription.js +3 -0
- package/dist/subscription/subscription.js.map +1 -0
- package/dist/subscription/tier.d.ts +3 -0
- package/dist/subscription/tier.d.ts.map +1 -0
- package/dist/subscription/tier.js +5 -0
- package/dist/subscription/tier.js.map +1 -0
- package/dist/users/index.d.ts +4 -0
- package/dist/users/index.d.ts.map +1 -0
- package/dist/users/index.js +20 -0
- package/dist/users/index.js.map +1 -0
- package/dist/users/role.d.ts +3 -0
- package/dist/users/role.d.ts.map +1 -0
- package/dist/users/role.js +12 -0
- package/dist/users/role.js.map +1 -0
- package/dist/users/status.d.ts +3 -0
- package/dist/users/status.d.ts.map +1 -0
- package/dist/users/status.js +12 -0
- package/dist/users/status.js.map +1 -0
- package/dist/users/user.d.ts +16 -0
- package/dist/users/user.d.ts.map +1 -0
- package/dist/users/user.js +3 -0
- package/dist/users/user.js.map +1 -0
- package/package.json +1 -1
- package/src/common/currency.ts +9 -1
- package/src/common/index.ts +1 -3
- package/src/common/meal_type.ts +3 -1
- package/src/common/temperature.ts +2 -1
- package/src/common/unit.ts +1 -0
- package/src/core/entity.ts +13 -4
- package/src/core/errors.ts +207 -52
- package/src/core/index.ts +0 -1
- package/src/core/locale.ts +4 -0
- package/src/core/timestamp.ts +1 -4
- package/src/equipment/entity.ts +4 -11
- package/src/equipment/user.ts +4 -6
- package/src/feed/recipe.ts +3 -3
- package/src/index.ts +2 -2
- package/src/ingredients/entity.ts +4 -11
- package/src/ingredients/user.ts +4 -6
- package/src/limits/limits.ts +1 -1
- package/src/limits/usage.ts +8 -2
- package/src/recipes/index.ts +5 -0
- package/src/recipes/meta.ts +0 -2
- package/src/recipes/recipe.ts +0 -2
- package/src/recipes/request.ts +26 -0
- package/src/recipes/stats.ts +3 -1
- package/src/recipes/user.ts +10 -0
- package/src/reports/report.ts +0 -3
- package/src/settings/settings.ts +1 -0
- package/src/shopping/equipment.ts +6 -1
- package/src/shopping/ingredient.ts +10 -3
- package/src/subscription/index.ts +9 -0
- package/src/{subscriptions → subscription}/member.ts +3 -3
- package/src/subscription/sharing.ts +5 -0
- package/src/subscription/subscription.ts +24 -0
- package/src/{iam → users}/user.ts +2 -0
- package/src/common/currency_code.ts +0 -10
- package/src/common/temperature_unit.ts +0 -2
- package/src/core/region.ts +0 -11
- package/src/interactions/collection.ts +0 -7
- package/src/interactions/cooked.ts +0 -6
- package/src/interactions/event.ts +0 -11
- package/src/interactions/event_type.ts +0 -9
- package/src/interactions/index.ts +0 -6
- package/src/interactions/rated.ts +0 -6
- package/src/interactions/saved.ts +0 -6
- package/src/recipes/status.ts +0 -8
- package/src/subscriptions/index.ts +0 -8
- package/src/subscriptions/subscription.ts +0 -22
- /package/src/common/{measurement_system.ts → measurement.ts} +0 -0
- /package/src/{subscriptions/billing_period.ts → subscription/billing.ts} +0 -0
- /package/src/{subscriptions → subscription}/member_status.ts +0 -0
- /package/src/{subscriptions/subscription_role.ts → subscription/role.ts} +0 -0
- /package/src/{subscriptions/subscription_status.ts → subscription/status.ts} +0 -0
- /package/src/{subscriptions → subscription}/store.ts +0 -0
- /package/src/{subscriptions/subscription_tier.ts → subscription/tier.ts} +0 -0
- /package/src/{iam → users}/index.ts +0 -0
- /package/src/{iam → users}/role.ts +0 -0
- /package/src/{iam → users}/status.ts +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export declare const CURRENCY_CODE_VALUES: readonly ["AED", "CAD", "EGP", "EUR", "SAR", "USD"];
|
|
2
|
+
export type CurrencyCode = (typeof CURRENCY_CODE_VALUES)[number];
|
|
2
3
|
export interface Currency {
|
|
3
4
|
amount: number;
|
|
4
5
|
currency: CurrencyCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../src/common/currency.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../src/common/currency.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,qDAOvB,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,YAAY,CAAC;CACxB"}
|
package/dist/common/currency.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency.js","sourceRoot":"","sources":["../../src/common/currency.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"currency.js","sourceRoot":"","sources":["../../src/common/currency.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG;IAClC,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;CACG,CAAC"}
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
export * from "./allergen";
|
|
2
2
|
export * from "./cuisine";
|
|
3
3
|
export * from "./currency";
|
|
4
|
-
export * from "./currency_code";
|
|
5
4
|
export * from "./dietary_tag";
|
|
6
5
|
export * from "./difficulty";
|
|
7
6
|
export * from "./meal_type";
|
|
8
|
-
export * from "./
|
|
7
|
+
export * from "./measurement";
|
|
9
8
|
export * from "./nutrition";
|
|
10
9
|
export * from "./spiciness";
|
|
11
|
-
export * from "./temperature_unit";
|
|
12
10
|
export * from "./temperature";
|
|
13
11
|
export * from "./unit";
|
|
14
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC"}
|
package/dist/common/index.js
CHANGED
|
@@ -17,14 +17,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./allergen"), exports);
|
|
18
18
|
__exportStar(require("./cuisine"), exports);
|
|
19
19
|
__exportStar(require("./currency"), exports);
|
|
20
|
-
__exportStar(require("./currency_code"), exports);
|
|
21
20
|
__exportStar(require("./dietary_tag"), exports);
|
|
22
21
|
__exportStar(require("./difficulty"), exports);
|
|
23
22
|
__exportStar(require("./meal_type"), exports);
|
|
24
|
-
__exportStar(require("./
|
|
23
|
+
__exportStar(require("./measurement"), exports);
|
|
25
24
|
__exportStar(require("./nutrition"), exports);
|
|
26
25
|
__exportStar(require("./spiciness"), exports);
|
|
27
|
-
__exportStar(require("./temperature_unit"), exports);
|
|
28
26
|
__exportStar(require("./temperature"), exports);
|
|
29
27
|
__exportStar(require("./unit"), exports);
|
|
30
28
|
//# sourceMappingURL=index.js.map
|
package/dist/common/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAC3B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAC3B,gDAA8B;AAC9B,+CAA6B;AAC7B,8CAA4B;AAC5B,gDAA8B;AAC9B,8CAA4B;AAC5B,8CAA4B;AAC5B,gDAA8B;AAC9B,yCAAuB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const MEAL_TYPE_VALUES: readonly ["appetizer", "breakfast", "brunch", "dessert", "dinner", "drink", "lunch", "
|
|
1
|
+
export declare const MEAL_TYPE_VALUES: readonly ["appetizer", "breakfast", "brunch", "condiment", "dessert", "dinner", "drink", "lunch", "salad", "side", "snack", "soup"];
|
|
2
2
|
export type MealType = (typeof MEAL_TYPE_VALUES)[number];
|
|
3
3
|
//# sourceMappingURL=meal_type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meal_type.d.ts","sourceRoot":"","sources":["../../src/common/meal_type.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"meal_type.d.ts","sourceRoot":"","sources":["../../src/common/meal_type.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,qIAanB,CAAC;AACX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/common/meal_type.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meal_type.js","sourceRoot":"","sources":["../../src/common/meal_type.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG;IAC9B,WAAW;IACX,WAAW;IACX,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;
|
|
1
|
+
{"version":3,"file":"meal_type.js","sourceRoot":"","sources":["../../src/common/meal_type.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG;IAC9B,WAAW;IACX,WAAW;IACX,QAAQ;IACR,WAAW;IACX,SAAS;IACT,QAAQ;IACR,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;CACE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measurement.d.ts","sourceRoot":"","sources":["../../src/common/measurement.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,iCAAkC,CAAC;AACzE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measurement.js","sourceRoot":"","sources":["../../src/common/measurement.ts"],"names":[],"mappings":";;;AAAa,QAAA,yBAAyB,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAU,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export declare const TEMPERATURE_UNIT_VALUES: readonly ["celsius", "fahrenheit"];
|
|
2
|
+
export type TemperatureUnit = (typeof TEMPERATURE_UNIT_VALUES)[number];
|
|
2
3
|
export interface Temperature {
|
|
3
4
|
unit: TemperatureUnit;
|
|
4
5
|
value: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temperature.d.ts","sourceRoot":"","sources":["../../src/common/temperature.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"temperature.d.ts","sourceRoot":"","sources":["../../src/common/temperature.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,oCAAqC,CAAC;AAC1E,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temperature.js","sourceRoot":"","sources":["../../src/common/temperature.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"temperature.js","sourceRoot":"","sources":["../../src/common/temperature.ts"],"names":[],"mappings":";;;AAAa,QAAA,uBAAuB,GAAG,CAAC,SAAS,EAAE,YAAY,CAAU,CAAC"}
|
package/dist/common/unit.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const UNIT_VALUES: readonly ["ml", "l", "tsp", "tbsp", "fl_oz", "cup", "pint", "quart", "gallon", "mg", "g", "kg", "oz", "lb", "piece", "whole", "half", "quarter", "slice", "serving", "clove", "stalk", "sprig", "leaf", "bunch", "head", "fillet", "stick", "sheet", "can", "package", "bottle", "jar", "handful", "pinch", "dash", "drop"];
|
|
1
|
+
export declare const UNIT_VALUES: readonly ["ml", "l", "tsp", "tbsp", "fl_oz", "cup", "pint", "quart", "gallon", "mg", "g", "kg", "oz", "lb", "piece", "whole", "half", "quarter", "scoop", "slice", "serving", "clove", "stalk", "sprig", "leaf", "bunch", "head", "fillet", "stick", "sheet", "can", "package", "bottle", "jar", "handful", "pinch", "dash", "drop"];
|
|
2
2
|
export type Unit = (typeof UNIT_VALUES)[number];
|
|
3
3
|
//# sourceMappingURL=unit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unit.d.ts","sourceRoot":"","sources":["../../src/common/unit.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"unit.d.ts","sourceRoot":"","sources":["../../src/common/unit.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,sUA+Cd,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/common/unit.js
CHANGED
package/dist/common/unit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unit.js","sourceRoot":"","sources":["../../src/common/unit.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG;IACzB,kBAAkB;IAClB,IAAI;IACJ,GAAG;IACH,oBAAoB;IACpB,KAAK;IACL,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;IACR,kBAAkB;IAClB,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,oBAAoB;IACpB,IAAI;IACJ,IAAI;IACJ,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,MAAM;IACN,SAAS;IACT,OAAO;IACP,SAAS;IACT,mBAAmB;IACnB,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,OAAO;IACP,OAAO;IACP,YAAY;IACZ,KAAK;IACL,SAAS;IACT,QAAQ;IACR,KAAK;IACL,YAAY;IACZ,SAAS;IACT,OAAO;IACP,MAAM;IACN,MAAM;CACE,CAAC"}
|
|
1
|
+
{"version":3,"file":"unit.js","sourceRoot":"","sources":["../../src/common/unit.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG;IACzB,kBAAkB;IAClB,IAAI;IACJ,GAAG;IACH,oBAAoB;IACpB,KAAK;IACL,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;IACR,kBAAkB;IAClB,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,oBAAoB;IACpB,IAAI;IACJ,IAAI;IACJ,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,MAAM;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACP,SAAS;IACT,mBAAmB;IACnB,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,OAAO;IACP,OAAO;IACP,YAAY;IACZ,KAAK;IACL,SAAS;IACT,QAAQ;IACR,KAAK;IACL,YAAY;IACZ,SAAS;IACT,OAAO;IACP,MAAM;IACN,MAAM;CACE,CAAC"}
|
package/dist/core/entity.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnixTimestamp } from "./timestamp";
|
|
2
|
+
export declare const ENTITY_STATUSES: readonly ["active", "archived", "deleted", "flagged", "pending"];
|
|
3
|
+
export type EntityStatus = (typeof ENTITY_STATUSES)[number];
|
|
2
4
|
export interface Entity {
|
|
3
5
|
id: string;
|
|
4
|
-
createdAt:
|
|
5
|
-
updatedAt:
|
|
6
|
-
deletedAt:
|
|
6
|
+
createdAt: UnixTimestamp;
|
|
7
|
+
updatedAt: UnixTimestamp;
|
|
8
|
+
deletedAt: UnixTimestamp | null;
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/core/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/core/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,eAAO,MAAM,eAAe,kEAMlB,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,aAAa,CAAC;IACzB,SAAS,EAAE,aAAa,CAAC;IACzB,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;CACjC"}
|
package/dist/core/entity.js
CHANGED
package/dist/core/entity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/core/entity.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/core/entity.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAG;IAC7B,QAAQ;IACR,UAAU;IACV,SAAS;IACT,SAAS;IACT,SAAS;CACD,CAAC"}
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -1,44 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import { UnixTimestamp } from "./timestamp";
|
|
2
|
+
export declare const APP_ERROR_CODES: readonly ["bad-request", "unauthorized", "forbidden", "not-found", "conflict", "validation-error", "quota-exceeded", "rate-limited", "internal-error", "service-unavailable"];
|
|
3
|
+
export type AppErrorCode = (typeof APP_ERROR_CODES)[number];
|
|
4
|
+
export declare const HTTP_STATUS_MAP: Record<AppErrorCode, number>;
|
|
5
|
+
export interface BaseErrorContext {
|
|
6
|
+
requestId?: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface ValidationErrorContext extends BaseErrorContext {
|
|
10
|
+
fields: Array<{
|
|
11
|
+
path: string;
|
|
12
|
+
message: string;
|
|
13
|
+
code?: string;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
export interface QuotaErrorContext extends BaseErrorContext {
|
|
17
|
+
quotaType: "daily" | "monthly";
|
|
18
|
+
resource: string;
|
|
19
|
+
limit: number;
|
|
20
|
+
used: number;
|
|
21
|
+
resetsAt?: UnixTimestamp;
|
|
22
|
+
}
|
|
23
|
+
export interface RateLimitErrorContext extends BaseErrorContext {
|
|
24
|
+
retryAfterSeconds?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface NotFoundErrorContext extends BaseErrorContext {
|
|
27
|
+
resourceType: string;
|
|
28
|
+
resourceId?: string;
|
|
29
|
+
}
|
|
3
30
|
export declare class AppError extends Error {
|
|
4
31
|
readonly code: AppErrorCode;
|
|
5
|
-
readonly context
|
|
6
|
-
|
|
32
|
+
readonly context: BaseErrorContext;
|
|
33
|
+
readonly statusCode: number;
|
|
34
|
+
constructor(code: AppErrorCode, message: string, context?: BaseErrorContext);
|
|
7
35
|
toJSON(): {
|
|
8
|
-
|
|
9
|
-
code: "bad-request" | "conflict" | "daily-limit-reached" | "forbidden" | "internal-error" | "low-confidence" | "monthly-limit-reached" | "not-found" | "no-recipe-found" | "unauthorized" | "unsafe-content" | "validation-error";
|
|
36
|
+
code: AppErrorCode;
|
|
10
37
|
message: string;
|
|
11
|
-
|
|
38
|
+
details?: Record<string, unknown>;
|
|
39
|
+
requestId?: string;
|
|
12
40
|
};
|
|
41
|
+
withRequestId(requestId: string): AppError;
|
|
13
42
|
}
|
|
14
|
-
export declare
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
constructor(message: string, context?: Record<string, unknown>);
|
|
43
|
+
export declare function isAppError(error: unknown): error is AppError;
|
|
44
|
+
export declare function isAppErrorCode(code: unknown): code is AppErrorCode;
|
|
45
|
+
export declare class BadRequestError extends AppError {
|
|
46
|
+
constructor(message: string, context?: BaseErrorContext);
|
|
19
47
|
}
|
|
20
48
|
export declare class UnauthorizedError extends AppError {
|
|
21
|
-
constructor(message
|
|
49
|
+
constructor(message?: string, context?: BaseErrorContext);
|
|
22
50
|
}
|
|
23
51
|
export declare class ForbiddenError extends AppError {
|
|
24
|
-
constructor(message
|
|
52
|
+
constructor(message?: string, context?: BaseErrorContext);
|
|
53
|
+
}
|
|
54
|
+
export declare class NotFoundError extends AppError {
|
|
55
|
+
constructor(resourceType: string, resourceId?: string, context?: Omit<NotFoundErrorContext, "resourceType" | "resourceId">);
|
|
25
56
|
}
|
|
26
57
|
export declare class ConflictError extends AppError {
|
|
27
|
-
constructor(message: string, context?:
|
|
58
|
+
constructor(message: string, context?: BaseErrorContext);
|
|
28
59
|
}
|
|
29
|
-
export declare class
|
|
30
|
-
|
|
60
|
+
export declare class ValidationError extends AppError {
|
|
61
|
+
readonly fields: ValidationErrorContext["fields"];
|
|
62
|
+
constructor(message: string, fields?: ValidationErrorContext["fields"], context?: Omit<ValidationErrorContext, "fields">);
|
|
63
|
+
static fromFieldErrors(fields: ValidationErrorContext["fields"], context?: Omit<ValidationErrorContext, "fields">): ValidationError;
|
|
31
64
|
}
|
|
32
|
-
export declare class
|
|
33
|
-
|
|
65
|
+
export declare class QuotaExceededError extends AppError {
|
|
66
|
+
readonly quotaType: "daily" | "monthly";
|
|
67
|
+
readonly resource: string;
|
|
68
|
+
readonly limit: number;
|
|
69
|
+
readonly used: number;
|
|
70
|
+
readonly resetsAt?: string;
|
|
71
|
+
constructor(quotaType: "daily" | "monthly", resource: string, limit: number, used: number, resetsAt?: string, context?: Omit<QuotaErrorContext, "quotaType" | "resource" | "limit" | "used" | "resetsAt">);
|
|
34
72
|
}
|
|
35
|
-
export declare class
|
|
36
|
-
|
|
73
|
+
export declare class RateLimitedError extends AppError {
|
|
74
|
+
readonly retryAfterSeconds?: number;
|
|
75
|
+
constructor(message?: string, retryAfterSeconds?: number, context?: Omit<RateLimitErrorContext, "retryAfterSeconds">);
|
|
37
76
|
}
|
|
38
|
-
export declare class
|
|
39
|
-
constructor(
|
|
77
|
+
export declare class InternalError extends AppError {
|
|
78
|
+
constructor(message?: string, context?: BaseErrorContext);
|
|
79
|
+
static wrap(error: unknown, context?: BaseErrorContext): InternalError;
|
|
40
80
|
}
|
|
41
|
-
export declare class
|
|
42
|
-
constructor(
|
|
81
|
+
export declare class ServiceUnavailableError extends AppError {
|
|
82
|
+
constructor(service: string, message?: string, context?: BaseErrorContext);
|
|
43
83
|
}
|
|
44
84
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,eAAO,MAAM,eAAe,+KAWlB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAWxD,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D,MAAM,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAsB,SAAQ,gBAAg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EAChD,OAAO,GAAE,gBAAqB;IAMhC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,gBAAqB,GAAG,aAAa;CAW3E;AAED,qBAAa,uBAAwB,SAAQ,QAAQ;gBAEjD,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,GAAE,gBAAqB;CASjC"}
|
package/dist/core/errors.js
CHANGED
|
@@ -1,108 +1,165 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
14
|
+
exports.ServiceUnavailableError = exports.InternalError = exports.RateLimitedError = exports.QuotaExceededError = exports.ValidationError = exports.ConflictError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = exports.AppError = exports.HTTP_STATUS_MAP = exports.APP_ERROR_CODES = void 0;
|
|
15
|
+
exports.isAppError = isAppError;
|
|
16
|
+
exports.isAppErrorCode = isAppErrorCode;
|
|
17
|
+
exports.APP_ERROR_CODES = [
|
|
5
18
|
"bad-request",
|
|
6
|
-
"
|
|
7
|
-
"daily-limit-reached",
|
|
19
|
+
"unauthorized",
|
|
8
20
|
"forbidden",
|
|
9
|
-
"internal-error",
|
|
10
|
-
"low-confidence",
|
|
11
|
-
"monthly-limit-reached",
|
|
12
21
|
"not-found",
|
|
13
|
-
"
|
|
14
|
-
"unauthorized",
|
|
15
|
-
"unsafe-content",
|
|
22
|
+
"conflict",
|
|
16
23
|
"validation-error",
|
|
24
|
+
"quota-exceeded",
|
|
25
|
+
"rate-limited",
|
|
26
|
+
"internal-error",
|
|
27
|
+
"service-unavailable",
|
|
17
28
|
];
|
|
29
|
+
exports.HTTP_STATUS_MAP = {
|
|
30
|
+
"bad-request": 400,
|
|
31
|
+
unauthorized: 401,
|
|
32
|
+
forbidden: 403,
|
|
33
|
+
"not-found": 404,
|
|
34
|
+
conflict: 409,
|
|
35
|
+
"validation-error": 422,
|
|
36
|
+
"quota-exceeded": 429,
|
|
37
|
+
"rate-limited": 429,
|
|
38
|
+
"internal-error": 500,
|
|
39
|
+
"service-unavailable": 503,
|
|
40
|
+
};
|
|
18
41
|
class AppError extends Error {
|
|
19
|
-
constructor(code, message, context) {
|
|
42
|
+
constructor(code, message, context = {}) {
|
|
20
43
|
super(message);
|
|
21
44
|
this.name = "AppError";
|
|
22
45
|
this.code = code;
|
|
23
46
|
this.context = context;
|
|
47
|
+
this.statusCode = exports.HTTP_STATUS_MAP[code];
|
|
24
48
|
if (Error.captureStackTrace) {
|
|
25
|
-
Error.captureStackTrace(this,
|
|
49
|
+
Error.captureStackTrace(this, this.constructor);
|
|
26
50
|
}
|
|
51
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
27
52
|
}
|
|
28
53
|
toJSON() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
54
|
+
const _a = this.context, { requestId } = _a, details = __rest(_a, ["requestId"]);
|
|
55
|
+
return Object.assign(Object.assign({ code: this.code, message: this.message }, (Object.keys(details).length > 0 && { details })), (requestId && { requestId }));
|
|
56
|
+
}
|
|
57
|
+
withRequestId(requestId) {
|
|
58
|
+
return new this.constructor(this.code, this.message, Object.assign(Object.assign({}, this.context), { requestId }));
|
|
35
59
|
}
|
|
36
60
|
}
|
|
37
61
|
exports.AppError = AppError;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
super("validation-error", message, context);
|
|
41
|
-
this.name = "ValidationError";
|
|
42
|
-
}
|
|
62
|
+
function isAppError(error) {
|
|
63
|
+
return error instanceof AppError;
|
|
43
64
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
65
|
+
function isAppErrorCode(code) {
|
|
66
|
+
return (typeof code === "string" && exports.APP_ERROR_CODES.includes(code));
|
|
67
|
+
}
|
|
68
|
+
class BadRequestError extends AppError {
|
|
69
|
+
constructor(message, context = {}) {
|
|
70
|
+
super("bad-request", message, context);
|
|
71
|
+
this.name = "BadRequestError";
|
|
49
72
|
}
|
|
50
73
|
}
|
|
51
|
-
exports.
|
|
74
|
+
exports.BadRequestError = BadRequestError;
|
|
52
75
|
class UnauthorizedError extends AppError {
|
|
53
|
-
constructor(message, context) {
|
|
76
|
+
constructor(message = "Authentication required", context = {}) {
|
|
54
77
|
super("unauthorized", message, context);
|
|
55
78
|
this.name = "UnauthorizedError";
|
|
56
79
|
}
|
|
57
80
|
}
|
|
58
81
|
exports.UnauthorizedError = UnauthorizedError;
|
|
59
82
|
class ForbiddenError extends AppError {
|
|
60
|
-
constructor(message, context) {
|
|
83
|
+
constructor(message = "You do not have permission to perform this action", context = {}) {
|
|
61
84
|
super("forbidden", message, context);
|
|
62
85
|
this.name = "ForbiddenError";
|
|
63
86
|
}
|
|
64
87
|
}
|
|
65
88
|
exports.ForbiddenError = ForbiddenError;
|
|
89
|
+
class NotFoundError extends AppError {
|
|
90
|
+
constructor(resourceType, resourceId, context = {}) {
|
|
91
|
+
const message = resourceId
|
|
92
|
+
? `${resourceType} not found: ${resourceId}`
|
|
93
|
+
: `${resourceType} not found`;
|
|
94
|
+
super("not-found", message, Object.assign(Object.assign({}, context), { resourceType, resourceId }));
|
|
95
|
+
this.name = "NotFoundError";
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.NotFoundError = NotFoundError;
|
|
66
99
|
class ConflictError extends AppError {
|
|
67
|
-
constructor(message, context) {
|
|
100
|
+
constructor(message, context = {}) {
|
|
68
101
|
super("conflict", message, context);
|
|
69
102
|
this.name = "ConflictError";
|
|
70
103
|
}
|
|
71
104
|
}
|
|
72
105
|
exports.ConflictError = ConflictError;
|
|
73
|
-
class
|
|
74
|
-
constructor(message, context) {
|
|
75
|
-
super("
|
|
76
|
-
this.name = "
|
|
106
|
+
class ValidationError extends AppError {
|
|
107
|
+
constructor(message, fields = [], context = {}) {
|
|
108
|
+
super("validation-error", message, Object.assign(Object.assign({}, context), { fields }));
|
|
109
|
+
this.name = "ValidationError";
|
|
110
|
+
this.fields = fields;
|
|
111
|
+
}
|
|
112
|
+
static fromFieldErrors(fields, context = {}) {
|
|
113
|
+
const message = fields.length === 1
|
|
114
|
+
? fields[0].message
|
|
115
|
+
: `Validation failed: ${fields.length} errors`;
|
|
116
|
+
return new ValidationError(message, fields, context);
|
|
77
117
|
}
|
|
78
118
|
}
|
|
79
|
-
exports.
|
|
80
|
-
class
|
|
81
|
-
constructor(
|
|
82
|
-
|
|
83
|
-
|
|
119
|
+
exports.ValidationError = ValidationError;
|
|
120
|
+
class QuotaExceededError extends AppError {
|
|
121
|
+
constructor(quotaType, resource, limit, used, resetsAt, context = {}) {
|
|
122
|
+
const message = `${quotaType.charAt(0).toUpperCase() + quotaType.slice(1)} ${resource} limit reached (${used}/${limit})`;
|
|
123
|
+
super("quota-exceeded", message, Object.assign(Object.assign({}, context), { quotaType,
|
|
124
|
+
resource,
|
|
125
|
+
limit,
|
|
126
|
+
used,
|
|
127
|
+
resetsAt }));
|
|
128
|
+
this.name = "QuotaExceededError";
|
|
129
|
+
this.quotaType = quotaType;
|
|
130
|
+
this.resource = resource;
|
|
131
|
+
this.limit = limit;
|
|
132
|
+
this.used = used;
|
|
133
|
+
this.resetsAt = resetsAt;
|
|
84
134
|
}
|
|
85
135
|
}
|
|
86
|
-
exports.
|
|
87
|
-
class
|
|
88
|
-
constructor(
|
|
89
|
-
super("
|
|
90
|
-
this.name = "
|
|
136
|
+
exports.QuotaExceededError = QuotaExceededError;
|
|
137
|
+
class RateLimitedError extends AppError {
|
|
138
|
+
constructor(message = "Too many requests. Please try again later.", retryAfterSeconds, context = {}) {
|
|
139
|
+
super("rate-limited", message, Object.assign(Object.assign({}, context), { retryAfterSeconds }));
|
|
140
|
+
this.name = "RateLimitedError";
|
|
141
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
91
142
|
}
|
|
92
143
|
}
|
|
93
|
-
exports.
|
|
94
|
-
class
|
|
95
|
-
constructor(
|
|
96
|
-
super("
|
|
97
|
-
this.name = "
|
|
144
|
+
exports.RateLimitedError = RateLimitedError;
|
|
145
|
+
class InternalError extends AppError {
|
|
146
|
+
constructor(message = "An unexpected error occurred", context = {}) {
|
|
147
|
+
super("internal-error", message, context);
|
|
148
|
+
this.name = "InternalError";
|
|
149
|
+
}
|
|
150
|
+
static wrap(error, context = {}) {
|
|
151
|
+
const message = error instanceof Error ? error.message : "An unexpected error occurred";
|
|
152
|
+
return new InternalError(message, Object.assign(Object.assign({}, context), { originalError: error instanceof Error
|
|
153
|
+
? { name: error.name, message: error.message }
|
|
154
|
+
: String(error) }));
|
|
98
155
|
}
|
|
99
156
|
}
|
|
100
|
-
exports.
|
|
101
|
-
class
|
|
102
|
-
constructor(context) {
|
|
103
|
-
super("
|
|
104
|
-
this.name = "
|
|
157
|
+
exports.InternalError = InternalError;
|
|
158
|
+
class ServiceUnavailableError extends AppError {
|
|
159
|
+
constructor(service, message, context = {}) {
|
|
160
|
+
super("service-unavailable", message !== null && message !== void 0 ? message : `${service} is temporarily unavailable`, Object.assign(Object.assign({}, context), { service }));
|
|
161
|
+
this.name = "ServiceUnavailableError";
|
|
105
162
|
}
|
|
106
163
|
}
|
|
107
|
-
exports.
|
|
164
|
+
exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
108
165
|
//# sourceMappingURL=errors.js.map
|
package/dist/core/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAwGA,gCAEC;AAED,wCAIC;AA9GY,QAAA,eAAe,GAAG;IAC7B,aAAa;IACb,cAAc;IACd,WAAW;IACX,WAAW;IACX,UAAU;IACV,kBAAkB;IAClB,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,qBAAqB;CACb,CAAC;AAIE,QAAA,eAAe,GAAiC;IAC3D,aAAa,EAAE,GAAG;IAClB,YAAY,EAAE,GAAG;IACjB,SAAS,EAAE,GAAG;IACd,WAAW,EAAE,GAAG;IAChB,QAAQ,EAAE,GAAG;IACb,kBAAkB,EAAE,GAAG;IACvB,gBAAgB,EAAE,GAAG;IACrB,cAAc,EAAE,GAAG;IACnB,gBAAgB,EAAE,GAAG;IACrB,qBAAqB,EAAE,GAAG;CAC3B,CAAC;AAgCF,MAAa,QAAS,SAAQ,KAAK;IAKjC,YACE,IAAkB,EAClB,OAAe,EACf,UAA4B,EAAE;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,uBAAe,CAAC,IAAI,CAAC,CAAC;QAExC,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,S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