@shware/http 0.3.1 → 0.3.3

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/detail.ts"],"sourcesContent":["import type { ErrorReason } from './reason';\n\nexport enum DetailType {\n ERROR_INFO = 'ERROR_INFO',\n RETRY_INFO = 'RETRY_INFO',\n DEBUG_INFO = 'DEBUG_INFO',\n QUOTA_FAILURE = 'QUOTA_FAILURE',\n PRECONDITION_FAILURE = 'PRECONDITION_FAILURE',\n BAD_REQUEST = 'BAD_REQUEST',\n REQUEST_INFO = 'REQUEST_INFO',\n RESOURCE_INFO = 'RESOURCE_INFO',\n HELP = 'HELP',\n LOCALIZED_MESSAGE = 'LOCALIZED_MESSAGE',\n}\n\nexport interface ErrorInfo {\n type: DetailType.ERROR_INFO;\n reason: keyof ErrorReason;\n domain?: string;\n metadata?: { [key: string]: string };\n}\n\nexport interface RetryInfo {\n type: DetailType.RETRY_INFO;\n retryDelay: number;\n}\n\nexport interface DebugInfo {\n type: DetailType.DEBUG_INFO;\n stackEntries: string[];\n detail?: string;\n}\n\nexport interface QuotaFailure {\n type: DetailType.QUOTA_FAILURE;\n violations: { subject: string; description: string }[];\n}\n\nexport interface PreconditionFailure {\n type: DetailType.PRECONDITION_FAILURE;\n violations: { type: string; subject: string; description: string }[];\n}\n\nexport interface BadRequest {\n type: DetailType.BAD_REQUEST;\n fieldViolations: { field: string; description: string }[];\n}\n\nexport interface RequestInfo {\n type: DetailType.REQUEST_INFO;\n requestId: string;\n servingData: string;\n}\n\nexport interface ResourceInfo {\n type: DetailType.RESOURCE_INFO;\n resourceType: string;\n resourceName: string;\n owner: string;\n description: string;\n}\n\nexport interface Help {\n type: DetailType.HELP;\n links: { url: string; description: string }[];\n}\n\nexport interface LocalizedMessage {\n type: DetailType.LOCALIZED_MESSAGE;\n locale: string;\n message: string;\n}\n\nexport type Detail =\n | RetryInfo\n | DebugInfo\n | QuotaFailure\n | ErrorInfo\n | PreconditionFailure\n | BadRequest\n | RequestInfo\n | ResourceInfo\n | Help\n | LocalizedMessage;\n\n/**\n * Example usage:\n * const details = Details.new()\n * .requestInfo({ requestId: '1234567890', servingData: '/v1/tests' })\n * .errorInfo({ reason: 'ACCOUNT_LOCKED' });\n * */\nexport class Details {\n readonly list: Detail[] = [];\n private constructor() {}\n\n static new() {\n return new Details();\n }\n\n errorInfo(detail: Omit<ErrorInfo, 'type'>) {\n this.list.push({ type: DetailType.ERROR_INFO, ...detail });\n return this;\n }\n\n retryInfo(detail: Omit<RetryInfo, 'type'>) {\n this.list.push({ type: DetailType.RETRY_INFO, ...detail });\n return this;\n }\n\n debugInfo(detail: Omit<DebugInfo, 'type'>) {\n this.list.push({ type: DetailType.DEBUG_INFO, ...detail });\n return this;\n }\n\n quotaFailure(detail: Omit<QuotaFailure, 'type'>) {\n this.list.push({ type: DetailType.QUOTA_FAILURE, ...detail });\n return this;\n }\n\n preconditionFailure(detail: Omit<PreconditionFailure, 'type'>) {\n this.list.push({ type: DetailType.PRECONDITION_FAILURE, ...detail });\n return this;\n }\n\n badRequest(detail: Omit<BadRequest, 'type'>) {\n this.list.push({ type: DetailType.BAD_REQUEST, ...detail });\n return this;\n }\n\n requestInfo(detail: Omit<RequestInfo, 'type'>) {\n this.list.push({ type: DetailType.REQUEST_INFO, ...detail });\n return this;\n }\n\n resourceInfo(detail: Omit<ResourceInfo, 'type'>) {\n this.list.push({ type: DetailType.RESOURCE_INFO, ...detail });\n return this;\n }\n\n help(detail: Omit<Help, 'type'>) {\n this.list.push({ type: DetailType.HELP, ...detail });\n return this;\n }\n\n localizedMessage(detail: Omit<LocalizedMessage, 'type'>) {\n this.list.push({ type: DetailType.LOCALIZED_MESSAGE, ...detail });\n return this;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,YAAA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C,SAAK,KAAK,KAAK,EAAE,MAAM,qCAA0B,GAAG,OAAO,CAAC;AAC5D,WAAO;AAAA,EACT;AAAA,EAEA,KAAK,QAA4B;AAC/B,SAAK,KAAK,KAAK,EAAE,MAAM,mBAAiB,GAAG,OAAO,CAAC;AACnD,WAAO;AAAA,EACT;AAAA,EAEA,iBAAiB,QAAwC;AACvD,SAAK,KAAK,KAAK,EAAE,MAAM,6CAA8B,GAAG,OAAO,CAAC;AAChE,WAAO;AAAA,EACT;AACF;","names":["DetailType"]}
1
+ {"version":3,"sources":["../src/detail.ts"],"sourcesContent":["import type { ErrorReason } from './reason';\n\nexport enum DetailType {\n ERROR_INFO = 'ERROR_INFO',\n RETRY_INFO = 'RETRY_INFO',\n DEBUG_INFO = 'DEBUG_INFO',\n QUOTA_FAILURE = 'QUOTA_FAILURE',\n PRECONDITION_FAILURE = 'PRECONDITION_FAILURE',\n BAD_REQUEST = 'BAD_REQUEST',\n REQUEST_INFO = 'REQUEST_INFO',\n RESOURCE_INFO = 'RESOURCE_INFO',\n HELP = 'HELP',\n LOCALIZED_MESSAGE = 'LOCALIZED_MESSAGE',\n}\n\nexport interface ErrorInfo {\n type: DetailType.ERROR_INFO;\n reason: keyof ErrorReason | (string & {});\n domain?: string;\n metadata?: { [key: string]: string };\n}\n\nexport interface RetryInfo {\n type: DetailType.RETRY_INFO;\n retryDelay: number;\n}\n\nexport interface DebugInfo {\n type: DetailType.DEBUG_INFO;\n stackEntries: string[];\n detail?: string;\n}\n\nexport interface QuotaFailure {\n type: DetailType.QUOTA_FAILURE;\n violations: { subject: string; description: string }[];\n}\n\nexport interface PreconditionFailure {\n type: DetailType.PRECONDITION_FAILURE;\n violations: { type: string; subject: string; description: string }[];\n}\n\nexport interface BadRequest {\n type: DetailType.BAD_REQUEST;\n fieldViolations: { field: string; description: string }[];\n}\n\nexport interface RequestInfo {\n type: DetailType.REQUEST_INFO;\n requestId: string;\n servingData: string;\n}\n\nexport interface ResourceInfo {\n type: DetailType.RESOURCE_INFO;\n resourceType: string;\n resourceName: string;\n owner: string;\n description: string;\n}\n\nexport interface Help {\n type: DetailType.HELP;\n links: { url: string; description: string }[];\n}\n\nexport interface LocalizedMessage {\n type: DetailType.LOCALIZED_MESSAGE;\n locale: string;\n message: string;\n}\n\nexport type Detail =\n | RetryInfo\n | DebugInfo\n | QuotaFailure\n | ErrorInfo\n | PreconditionFailure\n | BadRequest\n | RequestInfo\n | ResourceInfo\n | Help\n | LocalizedMessage;\n\n/**\n * Example usage:\n * const details = Details.new()\n * .requestInfo({ requestId: '1234567890', servingData: '/v1/tests' })\n * .errorInfo({ reason: 'ACCOUNT_LOCKED' });\n * */\nexport class Details {\n readonly list: Detail[] = [];\n private constructor() {}\n\n static new() {\n return new Details();\n }\n\n errorInfo(detail: Omit<ErrorInfo, 'type'>) {\n this.list.push({ type: DetailType.ERROR_INFO, ...detail });\n return this;\n }\n\n retryInfo(detail: Omit<RetryInfo, 'type'>) {\n this.list.push({ type: DetailType.RETRY_INFO, ...detail });\n return this;\n }\n\n debugInfo(detail: Omit<DebugInfo, 'type'>) {\n this.list.push({ type: DetailType.DEBUG_INFO, ...detail });\n return this;\n }\n\n quotaFailure(detail: Omit<QuotaFailure, 'type'>) {\n this.list.push({ type: DetailType.QUOTA_FAILURE, ...detail });\n return this;\n }\n\n preconditionFailure(detail: Omit<PreconditionFailure, 'type'>) {\n this.list.push({ type: DetailType.PRECONDITION_FAILURE, ...detail });\n return this;\n }\n\n badRequest(detail: Omit<BadRequest, 'type'>) {\n this.list.push({ type: DetailType.BAD_REQUEST, ...detail });\n return this;\n }\n\n requestInfo(detail: Omit<RequestInfo, 'type'>) {\n this.list.push({ type: DetailType.REQUEST_INFO, ...detail });\n return this;\n }\n\n resourceInfo(detail: Omit<ResourceInfo, 'type'>) {\n this.list.push({ type: DetailType.RESOURCE_INFO, ...detail });\n return this;\n }\n\n help(detail: Omit<Help, 'type'>) {\n this.list.push({ type: DetailType.HELP, ...detail });\n return this;\n }\n\n local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,KAAK,EAAE,MAAM,iCAAwB,GAAG,OAAO,CAAC;AAC1D,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,QAAmC;AAC7C,SAAK,KAAK,KAAK,EAAE,MAAM,mCAAyB,GAAG,OAAO,CAAC;AAC3D,WAAO;AAAA,EACT;AAAA,EAEA,aAAa,QAAoC;AAC/C,SAAK,KAAK,KAAK,EAAE,MAAM,qCAA0B,GAAG,OAAO,CAAC;AAC5D,WAAO;AAAA,EACT;AAAA,EAEA,KAAK,QAA4B;AAC/B,SAAK,KAAK,KAAK,EAAE,MAAM,mBAAiB,GAAG,OAAO,CAAC;AACnD,WAAO;AAAA,EACT;AAAA,EAEA,iBAAiB,QAAwC;AACvD,SAAK,KAAK,KAAK,EAAE,MAAM,6CAA8B,GAAG,OAAO,CAAC;AAChE,WAAO;AAAA,EACT;AACF;","names":["DetailType"]}
package/dist/detail.d.cts CHANGED
@@ -14,7 +14,7 @@ declare enum DetailType {
14
14
  }
15
15
  interface ErrorInfo {
16
16
  type: DetailType.ERROR_INFO;
17
- reason: keyof ErrorReason;
17
+ reason: keyof ErrorReason | (string & {});
18
18
  domain?: string;
19
19
  metadata?: {
20
20
  [key: string]: string;
package/dist/detail.d.ts CHANGED
@@ -14,7 +14,7 @@ declare enum DetailType {
14
14
  }
15
15
  interface ErrorInfo {
16
16
  type: DetailType.ERROR_INFO;
17
- reason: keyof ErrorReason;
17
+ reason: keyof ErrorReason | (string & {});
18
18
  domain?: string;
19
19
  metadata?: {
20
20
  [key: string]: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/detail.ts"],"sourcesContent":["import type { ErrorReason } from './reason';\n\nexport enum DetailType {\n ERROR_INFO = 'ERROR_INFO',\n RETRY_INFO = 'RETRY_INFO',\n DEBUG_INFO = 'DEBUG_INFO',\n QUOTA_FAILURE = 'QUOTA_FAILURE',\n PRECONDITION_FAILURE = 'PRECONDITION_FAILURE',\n BAD_REQUEST = 'BAD_REQUEST',\n REQUEST_INFO = 'REQUEST_INFO',\n RESOURCE_INFO = 'RESOURCE_INFO',\n HELP = 'HELP',\n LOCALIZED_MESSAGE = 'LOCALIZED_MESSAGE',\n}\n\nexport interface ErrorInfo {\n type: DetailType.ERROR_INFO;\n reason: keyof ErrorReason;\n domain?: string;\n metadata?: { [key: string]: string };\n}\n\nexport interface RetryInfo {\n type: DetailType.RETRY_INFO;\n retryDelay: number;\n}\n\nexport interface DebugInfo {\n type: DetailType.DEBUG_INFO;\n stackEntries: string[];\n detail?: string;\n}\n\nexport interface QuotaFailure {\n type: DetailType.QUOTA_FAILURE;\n violations: { subject: string; description: string }[];\n}\n\nexport interface PreconditionFailure {\n type: DetailType.PRECONDITION_FAILURE;\n violations: { type: string; subject: string; description: string }[];\n}\n\nexport interface BadRequest {\n type: DetailType.BAD_REQUEST;\n fieldViolations: { field: string; description: string }[];\n}\n\nexport interface RequestInfo {\n type: DetailType.REQUEST_INFO;\n requestId: string;\n servingData: string;\n}\n\nexport interface ResourceInfo {\n type: DetailType.RESOURCE_INFO;\n resourceType: string;\n resourceName: string;\n owner: string;\n description: string;\n}\n\nexport interface Help {\n type: DetailType.HELP;\n links: { url: string; description: string }[];\n}\n\nexport interface LocalizedMessage {\n type: DetailType.LOCALIZED_MESSAGE;\n locale: string;\n message: string;\n}\n\nexport type Detail =\n | RetryInfo\n | DebugInfo\n | QuotaFailure\n | ErrorInfo\n | PreconditionFailure\n | BadRequest\n | RequestInfo\n | ResourceInfo\n | Help\n | LocalizedMessage;\n\n/**\n * Example usage:\n * const details = Details.new()\n * .requestInfo({ requestId: '1234567890', servingData: '/v1/tests' })\n * .errorInfo({ reason: 'ACCOUNT_LOCKED' });\n * */\nexport class Details {\n readonly list: Detail[] = [];\n private constructor() {}\n\n static new() {\n return new Details();\n }\n\n errorInfo(detail: Omit<ErrorInfo, 'type'>) {\n this.list.push({ type: DetailType.ERROR_INFO, ...detail });\n return this;\n }\n\n retryInfo(detail: Omit<RetryInfo, 'type'>) {\n this.list.push({ type: DetailType.RETRY_INFO, ...detail });\n return this;\n }\n\n debugInfo(detail: Omit<DebugInfo, 'type'>) {\n this.list.push({ type: DetailType.DEBUG_INFO, ...detail });\n return this;\n }\n\n quotaFailure(detail: Omit<QuotaFailure, 'type'>) {\n this.list.push({ type: DetailType.QUOTA_FAILURE, ...detail });\n return this;\n }\n\n preconditionFailure(detail: Omit<PreconditionFailure, 'type'>) {\n this.list.push({ type: DetailType.PRECONDITION_FAILURE, ...detail });\n return this;\n }\n\n badRequest(detail: Omit<BadRequest, 'type'>) {\n this.list.push({ type: DetailType.BAD_REQUEST, ...detail });\n return this;\n }\n\n requestInfo(detail: Omit<RequestInfo, 'type'>) {\n this.list.push({ type: DetailType.REQUEST_INFO, ...detail });\n return this;\n }\n\n resourceInfo(detail: Omit<ResourceInfo, 'type'>) {\n this.list.push({ type: DetailType.RESOURCE_INFO, ...detail });\n return this;\n }\n\n help(detail: Omit<Help, 'type'>) {\n this.list.push({ type: DetailType.HELP, ...detail });\n return this;\n }\n\n localizedMessage(detail: Omit<LocalizedMessage, 'type'>) {\n this.list.push({ type: DetailType.LOCALIZED_MESSAGE, ...detail });\n return this;\n }\n}\n"],"mappings":";AAEO,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,YAAA,gBAAa;AACb,EAAAA,YAAA,gBAAa;AACb,EAAAA,YAAA,gBAAa;AACb,EAAAA,YAAA,mBAAgB;AAChB,EAAAA,YAAA,0BAAuB;AACvB,EAAAA,YAAA,iBAAc;AACd,EAAAA,YAAA,kBAAe;AACf,EAAAA,YAAA,mBAAgB;AAChB,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,uBAAoB;AAVV,SAAAA;AAAA,GAAA;AAyFL,IAAM,UAAN,MAAM,SAAQ;AAAA,EACV,OAAiB,CAAC;AAAA,EACnB,cAAc;AAAA,EAAC;AAAA,EAEvB,OAAO,MAAM;AACX,WAAO,IAAI,SAAQ;AAAA,EACrB;AAAA,EAEA,UAAU,QAAiC;AACzC,SAAK,KAAK,KAAK,EAAE,MAAM,+BAAuB,GAAG,OAAO,CAAC;AACzD,WAAO;AAAA,EACT;AAAA,EAEA,UAAU,QAAiC;AACzC,SAAK,KAAK,KAAK,EAAE,MAAM,+BAAuB,GAAG,OAAO,CAAC;AACzD,WAAO;AAAA,EACT;AAAA,EAEA,UAAU,QAAiC;AACzC,SAAK,KAAK,KAAK,EAAE,MAAM,+BAAuB,GAAG,OAAO,CAAC;AACzD,WAAO;AAAA,EACT;AAAA,EAEA,aAAa,QAAoC;AAC/C,SAAK,KAAK,KAAK,EAAE,MAAM,qCAA0B,GAAG,OAAO,CAAC;AAC5D,WAAO;AAAA,EACT;AAAA,EAEA,oBAAoB,QAA2C;AAC7D,SAAK,KAAK,KAAK,EAAE,MAAM,mDAAiC,GAAG,OAAO,CAAC;AACnE,WAAO;AAAA,EACT;AAAA,EAEA,WAAW,QAAkC;AAC3C,SAAK,KAAK,KAAK,EAAE,MAAM,iCAAwB,GAAG,OAAO,CAAC;AAC1D,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,QAAmC;AAC7C,SAAK,KAAK,KAAK,EAAE,MAAM,mCAAyB,GAAG,OAAO,CAAC;AAC3D,WAAO;AAAA,EACT;AAAA,EAEA,aAAa,QAAoC;AAC/C,SAAK,KAAK,KAAK,EAAE,MAAM,qCAA0B,GAAG,OAAO,CAAC;AAC5D,WAAO;AAAA,EACT;AAAA,EAEA,KAAK,QAA4B;AAC/B,SAAK,KAAK,KAAK,EAAE,MAAM,mBAAiB,GAAG,OAAO,CAAC;AACnD,WAAO;AAAA,EACT;AAAA,EAEA,iBAAiB,QAAwC;AACvD,SAAK,KAAK,KAAK,EAAE,MAAM,6CAA8B,GAAG,OAAO,CAAC;AAChE,WAAO;AAAA,EACT;AACF;","names":["DetailType"]}
1
+ {"version":3,"sources":["../src/detail.ts"],"sourcesContent":["import type { ErrorReason } from './reason';\n\nexport enum DetailType {\n ERROR_INFO = 'ERROR_INFO',\n RETRY_INFO = 'RETRY_INFO',\n DEBUG_INFO = 'DEBUG_INFO',\n QUOTA_FAILURE = 'QUOTA_FAILURE',\n PRECONDITION_FAILURE = 'PRECONDITION_FAILURE',\n BAD_REQUEST = 'BAD_REQUEST',\n REQUEST_INFO = 'REQUEST_INFO',\n RESOURCE_INFO = 'RESOURCE_INFO',\n HELP = 'HELP',\n LOCALIZED_MESSAGE = 'LOCALIZED_MESSAGE',\n}\n\nexport interface ErrorInfo {\n type: DetailType.ERROR_INFO;\n reason: keyof ErrorReason | (string & {});\n domain?: string;\n metadata?: { [key: string]: string };\n}\n\nexport interface RetryInfo {\n type: DetailType.RETRY_INFO;\n retryDelay: number;\n}\n\nexport interface DebugInfo {\n type: DetailType.DEBUG_INFO;\n stackEntries: string[];\n detail?: string;\n}\n\nexport interface QuotaFailure {\n type: DetailType.QUOTA_FAILURE;\n violations: { subject: string; description: string }[];\n}\n\nexport interface PreconditionFailure {\n type: DetailType.PRECONDITION_FAILURE;\n violations: { type: string; subject: string; description: string }[];\n}\n\nexport interface BadRequest {\n type: DetailType.BAD_REQUEST;\n fieldViolations: { field: string; description: string }[];\n}\n\nexport interface RequestInfo {\n type: DetailType.REQUEST_INFO;\n requestId: string;\n servingData: string;\n}\n\nexport interface ResourceInfo {\n type: DetailType.RESOURCE_INFO;\n resourceType: string;\n resourceName: string;\n owner: string;\n description: string;\n}\n\nexport interface Help {\n type: DetailType.HELP;\n links: { url: string; description: string }[];\n}\n\nexport interface LocalizedMessage {\n type: DetailType.LOCALIZED_MESSAGE;\n locale: string;\n message: string;\n}\n\nexport type Detail =\n | RetryInfo\n | DebugInfo\n | QuotaFailure\n | ErrorInfo\n | PreconditionFailure\n | BadRequest\n | RequestInfo\n | ResourceInfo\n | Help\n | LocalizedMessage;\n\n/**\n * Example usage:\n * const details = Details.new()\n * .requestInfo({ requestId: '1234567890', servingData: '/v1/tests' })\n * .errorInfo({ reason: 'ACCOUNT_LOCKED' });\n * */\nexport class Details {\n readonly list: Detail[] = [];\n private constructor() {}\n\n static new() {\n return new Details();\n }\n\n errorInfo(detail: Omit<ErrorInfo, 'type'>) {\n this.list.push({ type: DetailType.ERROR_INFO, ...detail });\n return this;\n }\n\n retryInfo(detail: Omit<RetryInfo, 'type'>) {\n this.list.push({ type: DetailType.RETRY_INFO, ...detail });\n return this;\n }\n\n debugInfo(detail: Omit<DebugInfo, 'type'>) {\n this.list.push({ type: DetailType.DEBUG_INFO, ...detail });\n return this;\n }\n\n quotaFailure(detail: Omit<QuotaFailure, 'type'>) {\n this.list.push({ type: DetailType.QUOTA_FAILURE, ...detail });\n return this;\n }\n\n preconditionFailure(detail: Omit<PreconditionFailure, 'type'>) {\n this.list.push({ type: DetailType.PRECONDITION_FAILURE, ...detail });\n return this;\n }\n\n badRequest(detail: Omit<BadRequest, 'type'>) {\n this.list.push({ type: DetailType.BAD_REQUEST, ...detail });\n return this;\n }\n\n requestInfo(detail: Omit<RequestInfo, 'type'>) {\n this.list.push({ type: DetailType.REQUEST_INFO, ...detail });\n return this;\n }\n\n resourceInfo(detail: Omit<ResourceInfo, 'type'>) {\n this.list.push({ type: DetailType.RESOURCE_INFO, ...detail });\n return this;\n }\n\n help(detail: Omit<Help, 'type'>) {\n this.list.push({ type: DetailType.HELP, ...detail });\n return this;\n }\n\n localizedMessage(detail: Omit<LocalizedMessage, 'type'>) {\n this.list.push({ type: DetailType.LOCALIZED_MESSAGE, ...detail });\n return this;\n }\n}\n"],"mappings":";AAEO,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,YAAA,gBAAa;AACb,EAAAA,YAAA,gBAAa;AACb,EAAAA,YAAA,gBAAa;AACb,EAAAA,YAAA,mBAAgB;AAChB,EAAAA,YAAA,0BAAuB;AACvB,EAAAA,YAAA,iBAAc;AACd,EAAAA,YAAA,kBAAe;AACf,EAAAA,YAAA,mBAAgB;AAChB,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,uBAAoB;AAVV,SAAAA;AAAA,GAAA;AAyFL,IAAM,UAAN,MAAM,SAAQ;A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,EACT;AACF;","names":["DetailType"]}
@@ -23,13 +23,19 @@ __export(token_bucket_exports, {
23
23
  TokenBucket: () => TokenBucket
24
24
  });
25
25
  module.exports = __toCommonJS(token_bucket_exports);
26
+ var INTERVAL_MAP = {
27
+ second: 1e3,
28
+ minute: 60 * 1e3,
29
+ hour: 60 * 60 * 1e3,
30
+ day: 24 * 60 * 60 * 1e3
31
+ };
26
32
  var TokenBucket = class {
27
33
  rate;
28
34
  capacity;
29
35
  requested;
30
36
  timer;
31
37
  tokens;
32
- constructor({ rate, capacity, requested }) {
38
+ constructor({ rate, capacity, requested, interval = "second" }) {
33
39
  if (rate <= 0) throw new Error("rate must be greater than 0");
34
40
  if (capacity <= 0) throw new Error("capacity must be greater than 0");
35
41
  if (requested <= 0) throw new Error("requested must be greater than 0");
@@ -43,7 +49,7 @@ var TokenBucket = class {
43
49
  const tokens = this.tokens + this.rate;
44
50
  this.tokens = Math.min(tokens, this.capacity);
45
51
  }
46
- }, 1e3);
52
+ }, INTERVAL_MAP[interval]);
47
53
  }
48
54
  wait(ms) {
49
55
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/token-bucket.ts"],"sourcesContent":["export interface TokenBucketOptions {\n rate: number;\n capacity: number;\n requested: number;\n}\n\nexport class TokenBucket {\n readonly rate: number;\n readonly capacity: number;\n readonly requested: number;\n private readonly timer: number | NodeJS.Timeout;\n private tokens: number;\n\n constructor({ rate, capacity, requested }: TokenBucketOptions) {\n if (rate <= 0) throw new Error('rate must be greater than 0');\n if (capacity <= 0) throw new Error('capacity must be greater than 0');\n if (requested <= 0) throw new Error('requested must be greater than 0');\n if (requested > capacity) throw new Error('requested must be less than or equal to capacity');\n\n this.rate = rate;\n this.capacity = capacity;\n this.requested = requested;\n this.tokens = capacity;\n this.timer = setInterval(() => {\n if (this.tokens < this.capacity) {\n const tokens = this.tokens + this.rate;\n this.tokens = Math.min(tokens, this.capacity);\n }\n }, 1000);\n }\n\n private wait(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n async removeTokens(): Promise<number> {\n while (this.tokens < this.requested) {\n const ms = Math.ceil((1000 * (this.requested - this.tokens)) / this.rate);\n await this.wait(ms);\n }\n this.tokens -= this.requested;\n return this.tokens;\n }\n\n destroy() {\n clearInterval(this.timer);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,cAAN,MAAkB;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACQ;AAAA,EACT;AAAA,EAER,YAAY,EAAE,MAAM,UAAU,UAAU,GAAuB;AAC7D,QAAI,QAAQ,EAAG,OAAM,IAAI,MAAM,6BAA6B;AAC5D,QAAI,YAAY,EAAG,OAAM,IAAI,MAAM,iCAAiC;AACpE,QAAI,aAAa,EAAG,OAAM,IAAI,MAAM,kCAAkC;AACtE,QAAI,YAAY,SAAU,OAAM,IAAI,MAAM,kDAAkD;AAE5F,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,YAAY;AACjB,SAAK,SAAS;AACd,SAAK,QAAQ,YAAY,MAAM;AAC7B,UAAI,KAAK,SAAS,KAAK,UAAU;AAC/B,cAAM,SAAS,KAAK,SAAS,KAAK;AAClC,aAAK,SAAS,KAAK,IAAI,QAAQ,KAAK,QAAQ;AAAA,MAC9C;AAAA,IACF,GAAG,GAAI;AAAA,EACT;AAAA,EAEQ,KAAK,IAA2B;AACtC,WAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAAA,EACzD;AAAA,EAEA,MAAM,eAAgC;AACpC,WAAO,KAAK,SAAS,KAAK,WAAW;AACnC,YAAM,KAAK,KAAK,KAAM,OAAQ,KAAK,YAAY,KAAK,UAAW,KAAK,IAAI;AACxE,YAAM,KAAK,KAAK,EAAE;AAAA,IACpB;AACA,SAAK,UAAU,KAAK;AACpB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,UAAU;AACR,kBAAc,KAAK,KAAK;AAAA,EAC1B;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/token-bucket.ts"],"sourcesContent":["type Interval = 'second' | 'minute' | 'hour' | 'day';\n\nconst INTERVAL_MAP: Record<Interval, number> = {\n second: 1000,\n minute: 60 * 1000,\n hour: 60 * 60 * 1000,\n day: 24 * 60 * 60 * 1000,\n};\n\nexport interface TokenBucketOptions {\n rate: number;\n capacity: number;\n requested: number;\n interval?: Interval;\n}\n\nexport class TokenBucket {\n readonly rate: number;\n readonly capacity: number;\n readonly requested: number;\n private readonly timer: number | NodeJS.Timeout;\n private tokens: number;\n\n constructor({ rate, capacity, requested, interval = 'second' }: TokenBucketOptions) {\n if (rate <= 0) throw new Error('rate must be greater than 0');\n if (capacity <= 0) throw new Error('capacity must be greater than 0');\n if (requested <= 0) throw new Error('requested must be greater than 0');\n if (requested > capacity) throw new Error('requested must be less than or equal to capacity');\n\n this.rate = rate;\n this.capacity = capacity;\n this.requested = requested;\n this.tokens = capacity;\n this.timer = setInterval(() => {\n if (this.tokens < this.capacity) {\n const tokens = this.tokens + this.rate;\n this.tokens = Math.min(tokens, this.capacity);\n }\n }, INTERVAL_MAP[interval]);\n }\n\n private wait(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n async removeTokens(): Promise<number> {\n while (this.tokens < this.requested) {\n const ms = Math.ceil((1000 * (this.requested - this.tokens)) / this.rate);\n await this.wait(ms);\n }\n this.tokens -= this.requested;\n return this.tokens;\n }\n\n destroy() {\n clearInterval(this.timer);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAM,eAAyC;AAAA,EAC7C,QAAQ;AAAA,EACR,QAAQ,KAAK;AAAA,EACb,MAAM,KAAK,KAAK;AAAA,EAChB,KAAK,KAAK,KAAK,KAAK;AACtB;AASO,IAAM,cAAN,MAAkB;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACQ;AAAA,EACT;AAAA,EAER,YAAY,EAAE,MAAM,UAAU,WAAW,WAAW,SAAS,GAAuB;AAClF,QAAI,QAAQ,EAAG,OAAM,IAAI,MAAM,6BAA6B;AAC5D,QAAI,YAAY,EAAG,OAAM,IAAI,MAAM,iCAAiC;AACpE,QAAI,aAAa,EAAG,OAAM,IAAI,MAAM,kCAAkC;AACtE,QAAI,YAAY,SAAU,OAAM,IAAI,MAAM,kDAAkD;AAE5F,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,YAAY;AACjB,SAAK,SAAS;AACd,SAAK,QAAQ,YAAY,MAAM;AAC7B,UAAI,KAAK,SAAS,KAAK,UAAU;AAC/B,cAAM,SAAS,KAAK,SAAS,KAAK;AAClC,aAAK,SAAS,KAAK,IAAI,QAAQ,KAAK,QAAQ;AAAA,MAC9C;AAAA,IACF,GAAG,aAAa,QAAQ,CAAC;AAAA,EAC3B;AAAA,EAEQ,KAAK,IAA2B;AACtC,WAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAAA,EACzD;AAAA,EAEA,MAAM,eAAgC;AACpC,WAAO,KAAK,SAAS,KAAK,WAAW;AACnC,YAAM,KAAK,KAAK,KAAM,OAAQ,KAAK,YAAY,KAAK,UAAW,KAAK,IAAI;AACxE,YAAM,KAAK,KAAK,EAAE;AAAA,IACpB;AACA,SAAK,UAAU,KAAK;AACpB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,UAAU;AACR,kBAAc,KAAK,KAAK;AAAA,EAC1B;AACF;","names":[]}
@@ -1,7 +1,9 @@
1
+ type Interval = 'second' | 'minute' | 'hour' | 'day';
1
2
  interface TokenBucketOptions {
2
3
  rate: number;
3
4
  capacity: number;
4
5
  requested: number;
6
+ interval?: Interval;
5
7
  }
6
8
  declare class TokenBucket {
7
9
  readonly rate: number;
@@ -9,7 +11,7 @@ declare class TokenBucket {
9
11
  readonly requested: number;
10
12
  private readonly timer;
11
13
  private tokens;
12
- constructor({ rate, capacity, requested }: TokenBucketOptions);
14
+ constructor({ rate, capacity, requested, interval }: TokenBucketOptions);
13
15
  private wait;
14
16
  removeTokens(): Promise<number>;
15
17
  destroy(): void;
@@ -1,7 +1,9 @@
1
+ type Interval = 'second' | 'minute' | 'hour' | 'day';
1
2
  interface TokenBucketOptions {
2
3
  rate: number;
3
4
  capacity: number;
4
5
  requested: number;
6
+ interval?: Interval;
5
7
  }
6
8
  declare class TokenBucket {
7
9
  readonly rate: number;
@@ -9,7 +11,7 @@ declare class TokenBucket {
9
11
  readonly requested: number;
10
12
  private readonly timer;
11
13
  private tokens;
12
- constructor({ rate, capacity, requested }: TokenBucketOptions);
14
+ constructor({ rate, capacity, requested, interval }: TokenBucketOptions);
13
15
  private wait;
14
16
  removeTokens(): Promise<number>;
15
17
  destroy(): void;
@@ -1,11 +1,17 @@
1
1
  // src/utils/token-bucket.ts
2
+ var INTERVAL_MAP = {
3
+ second: 1e3,
4
+ minute: 60 * 1e3,
5
+ hour: 60 * 60 * 1e3,
6
+ day: 24 * 60 * 60 * 1e3
7
+ };
2
8
  var TokenBucket = class {
3
9
  rate;
4
10
  capacity;
5
11
  requested;
6
12
  timer;
7
13
  tokens;
8
- constructor({ rate, capacity, requested }) {
14
+ constructor({ rate, capacity, requested, interval = "second" }) {
9
15
  if (rate <= 0) throw new Error("rate must be greater than 0");
10
16
  if (capacity <= 0) throw new Error("capacity must be greater than 0");
11
17
  if (requested <= 0) throw new Error("requested must be greater than 0");
@@ -19,7 +25,7 @@ var TokenBucket = class {
19
25
  const tokens = this.tokens + this.rate;
20
26
  this.tokens = Math.min(tokens, this.capacity);
21
27
  }
22
- }, 1e3);
28
+ }, INTERVAL_MAP[interval]);
23
29
  }
24
30
  wait(ms) {
25
31
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/token-bucket.ts"],"sourcesContent":["export interface TokenBucketOptions {\n rate: number;\n capacity: number;\n requested: number;\n}\n\nexport class TokenBucket {\n readonly rate: number;\n readonly capacity: number;\n readonly requested: number;\n private readonly timer: number | NodeJS.Timeout;\n private tokens: number;\n\n constructor({ rate, capacity, requested }: TokenBucketOptions) {\n if (rate <= 0) throw new Error('rate must be greater than 0');\n if (capacity <= 0) throw new Error('capacity must be greater than 0');\n if (requested <= 0) throw new Error('requested must be greater than 0');\n if (requested > capacity) throw new Error('requested must be less than or equal to capacity');\n\n this.rate = rate;\n this.capacity = capacity;\n this.requested = requested;\n this.tokens = capacity;\n this.timer = setInterval(() => {\n if (this.tokens < this.capacity) {\n const tokens = this.tokens + this.rate;\n this.tokens = Math.min(tokens, this.capacity);\n }\n }, 1000);\n }\n\n private wait(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n async removeTokens(): Promise<number> {\n while (this.tokens < this.requested) {\n const ms = Math.ceil((1000 * (this.requested - this.tokens)) / this.rate);\n await this.wait(ms);\n }\n this.tokens -= this.requested;\n return this.tokens;\n }\n\n destroy() {\n clearInterval(this.timer);\n }\n}\n"],"mappings":";AAMO,IAAM,cAAN,MAAkB;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACQ;AAAA,EACT;AAAA,EAER,YAAY,EAAE,MAAM,UAAU,UAAU,GAAuB;AAC7D,QAAI,QAAQ,EAAG,OAAM,IAAI,MAAM,6BAA6B;AAC5D,QAAI,YAAY,EAAG,OAAM,IAAI,MAAM,iCAAiC;AACpE,QAAI,aAAa,EAAG,OAAM,IAAI,MAAM,kCAAkC;AACtE,QAAI,YAAY,SAAU,OAAM,IAAI,MAAM,kDAAkD;AAE5F,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,YAAY;AACjB,SAAK,SAAS;AACd,SAAK,QAAQ,YAAY,MAAM;AAC7B,UAAI,KAAK,SAAS,KAAK,UAAU;AAC/B,cAAM,SAAS,KAAK,SAAS,KAAK;AAClC,aAAK,SAAS,KAAK,IAAI,QAAQ,KAAK,QAAQ;AAAA,MAC9C;AAAA,IACF,GAAG,GAAI;AAAA,EACT;AAAA,EAEQ,KAAK,IAA2B;AACtC,WAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAAA,EACzD;AAAA,EAEA,MAAM,eAAgC;AACpC,WAAO,KAAK,SAAS,KAAK,WAAW;AACnC,YAAM,KAAK,KAAK,KAAM,OAAQ,KAAK,YAAY,KAAK,UAAW,KAAK,IAAI;AACxE,YAAM,KAAK,KAAK,EAAE;AAAA,IACpB;AACA,SAAK,UAAU,KAAK;AACpB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,UAAU;AACR,kBAAc,KAAK,KAAK;AAAA,EAC1B;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/token-bucket.ts"],"sourcesContent":["type Interval = 'second' | 'minute' | 'hour' | 'day';\n\nconst INTERVAL_MAP: Record<Interval, number> = {\n second: 1000,\n minute: 60 * 1000,\n hour: 60 * 60 * 1000,\n day: 24 * 60 * 60 * 1000,\n};\n\nexport interface TokenBucketOptions {\n rate: number;\n capacity: number;\n requested: number;\n interval?: Interval;\n}\n\nexport class TokenBucket {\n readonly rate: number;\n readonly capacity: number;\n readonly requested: number;\n private readonly timer: number | NodeJS.Timeout;\n private tokens: number;\n\n constructor({ rate, capacity, requested, interval = 'second' }: TokenBucketOptions) {\n if (rate <= 0) throw new Error('rate must be greater than 0');\n if (capacity <= 0) throw new Error('capacity must be greater than 0');\n if (requested <= 0) throw new Error('requested must be greater than 0');\n if (requested > capacity) throw new Error('requested must be less than or equal to capacity');\n\n this.rate = rate;\n this.capacity = capacity;\n this.requested = requested;\n this.tokens = capacity;\n this.timer = setInterval(() => {\n if (this.tokens < this.capacity) {\n const tokens = this.tokens + this.rate;\n this.tokens = Math.min(tokens, this.capacity);\n }\n }, INTERVAL_MAP[interval]);\n }\n\n private wait(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n async removeTokens(): Promise<number> {\n while (this.tokens < this.requested) {\n const ms = Math.ceil((1000 * (this.requested - this.tokens)) / this.rate);\n await this.wait(ms);\n }\n this.tokens -= this.requested;\n return this.tokens;\n }\n\n destroy() {\n clearInterval(this.timer);\n }\n}\n"],"mappings":";AAEA,IAAM,eAAyC;AAAA,EAC7C,QAAQ;AAAA,EACR,QAAQ,KAAK;AAAA,EACb,MAAM,KAAK,KAAK;AAAA,EAChB,KAAK,KAAK,KAAK,KAAK;AACtB;AASO,IAAM,cAAN,MAAkB;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACQ;AAAA,EACT;AAAA,EAER,YAAY,EAAE,MAAM,UAAU,WAAW,WAAW,SAAS,GAAuB;AAClF,QAAI,QAAQ,EAAG,OAAM,IAAI,MAAM,6BAA6B;AAC5D,QAAI,YAAY,EAAG,OAAM,IAAI,MAAM,iCAAiC;AACpE,QAAI,aAAa,EAAG,OAAM,IAAI,MAAM,kCAAkC;AACtE,QAAI,YAAY,SAAU,OAAM,IAAI,MAAM,kDAAkD;AAE5F,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,YAAY;AACjB,SAAK,SAAS;AACd,SAAK,QAAQ,YAAY,MAAM;AAC7B,UAAI,KAAK,SAAS,KAAK,UAAU;AAC/B,cAAM,SAAS,KAAK,SAAS,KAAK;AAClC,aAAK,SAAS,KAAK,IAAI,QAAQ,KAAK,QAAQ;AAAA,MAC9C;AAAA,IACF,GAAG,aAAa,QAAQ,CAAC;AAAA,EAC3B;AAAA,EAEQ,KAAK,IAA2B;AACtC,WAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAAA,EACzD;AAAA,EAEA,MAAM,eAAgC;AACpC,WAAO,KAAK,SAAS,KAAK,WAAW;AACnC,YAAM,KAAK,KAAK,KAAM,OAAQ,KAAK,YAAY,KAAK,UAAW,KAAK,IAAI;AACxE,YAAM,KAAK,KAAK,EAAE;AAAA,IACpB;AACA,SAAK,UAAU,KAAK;AACpB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,UAAU;AACR,kBAAc,KAAK,KAAK;AAAA,EAC1B;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shware/http",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {