@pdfvector/util 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ export declare const billingHoldErrorCodes: readonly ["BILLING_UNPAID_INVOICE", "BILLING_DISPUTE", "BILLING_PAYMENT_METHOD_REQUIRED", "BILLING_LINKED_UNPAID_BALANCE", "BILLING_ACCOUNT_HOLD"];
2
+ export type BillingHoldErrorCode = (typeof billingHoldErrorCodes)[number];
3
+ export declare const creditsExhaustedErrorCode = "CREDITS_EXHAUSTED";
4
+ export type BillingHoldErrorData = {
5
+ code: BillingHoldErrorCode;
6
+ reason: string;
7
+ invoiceCount: number;
8
+ amountDue: number;
9
+ currency: string;
10
+ billingUrl: string;
11
+ payUrl: string | null;
12
+ };
13
+ export declare function isBillingHoldErrorCode(value: unknown): value is BillingHoldErrorCode;
14
+ //# sourceMappingURL=billing-hold-error-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-hold-error-codes.d.ts","sourceRoot":"","sources":["../../lib/billing-hold-error-codes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,YACjC,wBAAwB,EACxB,iBAAiB,EACjB,iCAAiC,EACjC,+BAA+B,EAC/B,sBAAsB,CACb,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E,eAAO,MAAM,yBAAyB,sBAAsB,CAAC;AAE7D,MAAM,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,OAAO,GACZ,KAAK,IAAI,oBAAoB,CAE/B"}
@@ -0,0 +1,11 @@
1
+ export const billingHoldErrorCodes = [
2
+ "BILLING_UNPAID_INVOICE",
3
+ "BILLING_DISPUTE",
4
+ "BILLING_PAYMENT_METHOD_REQUIRED",
5
+ "BILLING_LINKED_UNPAID_BALANCE",
6
+ "BILLING_ACCOUNT_HOLD",
7
+ ];
8
+ export const creditsExhaustedErrorCode = "CREDITS_EXHAUSTED";
9
+ export function isBillingHoldErrorCode(value) {
10
+ return billingHoldErrorCodes.some((code) => code === value);
11
+ }
@@ -0,0 +1,42 @@
1
+ import * as z from "zod";
2
+ export declare const listBillingHolds: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3
+ includeResolved: z.ZodDefault<z.ZodBoolean>;
4
+ }, z.core.$strip>, z.ZodObject<{
5
+ mode: z.ZodEnum<{
6
+ enforce: "enforce";
7
+ off: "off";
8
+ shadow: "shadow";
9
+ }>;
10
+ holds: z.ZodArray<z.ZodObject<{
11
+ workspaceId: z.ZodNumber;
12
+ workspaceName: z.ZodString;
13
+ reason: z.ZodString;
14
+ code: z.ZodString;
15
+ invoiceCount: z.ZodNumber;
16
+ amountDue: z.ZodNumber;
17
+ currency: z.ZodString;
18
+ linkedWorkspaceId: z.ZodNullable<z.ZodNumber>;
19
+ matchedBy: z.ZodNullable<z.ZodString>;
20
+ manual: z.ZodBoolean;
21
+ since: z.ZodDate;
22
+ resolvedAt: z.ZodNullable<z.ZodDate>;
23
+ exemptUntil: z.ZodNullable<z.ZodDate>;
24
+ emailsSent: z.ZodNumber;
25
+ }, z.core.$strip>>;
26
+ registry: z.ZodArray<z.ZodObject<{
27
+ kind: z.ZodString;
28
+ count: z.ZodNumber;
29
+ }, z.core.$strip>>;
30
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
31
+ export declare const overrideBillingHold: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
32
+ workspaceId: z.ZodNumber;
33
+ action: z.ZodEnum<{
34
+ clear: "clear";
35
+ hold: "hold";
36
+ unexempt: "unexempt";
37
+ }>;
38
+ days: z.ZodDefault<z.ZodNumber>;
39
+ }, z.core.$strip>, z.ZodObject<{
40
+ success: z.ZodBoolean;
41
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
42
+ //# sourceMappingURL=billing-holds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-holds.d.ts","sourceRoot":"","sources":["../../../../../../lib/contract/gateway/router/admin/billing-holds.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DAyB3B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;8DAQY,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { oc } from "@orpc/contract";
2
+ import * as z from "zod";
3
+ export const listBillingHolds = oc
4
+ .input(z.object({ includeResolved: z.boolean().default(false) }))
5
+ .output(z.object({
6
+ mode: z.enum(["off", "shadow", "enforce"]),
7
+ holds: z.array(z.object({
8
+ workspaceId: z.number(),
9
+ workspaceName: z.string(),
10
+ reason: z.string(),
11
+ code: z.string(),
12
+ invoiceCount: z.number(),
13
+ amountDue: z.number(),
14
+ currency: z.string(),
15
+ linkedWorkspaceId: z.number().nullable(),
16
+ matchedBy: z.string().nullable(),
17
+ manual: z.boolean(),
18
+ since: z.date(),
19
+ resolvedAt: z.date().nullable(),
20
+ exemptUntil: z.date().nullable(),
21
+ emailsSent: z.number(),
22
+ })),
23
+ registry: z.array(z.object({ kind: z.string(), count: z.number() })),
24
+ }));
25
+ export const overrideBillingHold = oc
26
+ .input(z.object({
27
+ workspaceId: z.number().int().positive(),
28
+ action: z.enum(["hold", "clear", "unexempt"]),
29
+ days: z.number().int().min(1).max(3650).default(30),
30
+ }))
31
+ .output(z.object({ success: z.boolean() }));
@@ -1,4 +1,5 @@
1
1
  export * from "./admin/billing.js";
2
+ export * from "./admin/billing-holds.js";
2
3
  export * from "./admin/blog.js";
3
4
  export * from "./admin/feedback.js";
4
5
  export * from "./admin/instances.js";
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../../../lib/contract/gateway/router/admin.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../../../lib/contract/gateway/router/admin.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from "./admin/billing.js";
2
+ export * from "./admin/billing-holds.js";
2
3
  export * from "./admin/blog.js";
3
4
  export * from "./admin/feedback.js";
4
5
  export * from "./admin/instances.js";
@@ -15,4 +15,58 @@ export declare const update: import("@orpc/contract").ContractProcedureBuilderWi
15
15
  succeedURL: z.ZodString;
16
16
  returnURL: z.ZodString;
17
17
  }, z.core.$strip>, z.ZodOptional<z.ZodString>, Record<never, never>, Record<never, never>>;
18
+ /** The workspace's billing hold (unpaid invoices or a payment dispute), if any. */
19
+ export declare const hold: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodObject<{
20
+ mode: z.ZodEnum<{
21
+ enforce: "enforce";
22
+ off: "off";
23
+ shadow: "shadow";
24
+ }>;
25
+ hold: z.ZodNullable<z.ZodObject<{
26
+ reason: z.ZodEnum<{
27
+ canceled_unpaid: "canceled_unpaid";
28
+ dispute: "dispute";
29
+ dispute_lost: "dispute_lost";
30
+ linked_unpaid: "linked_unpaid";
31
+ manual: "manual";
32
+ overdue_invoice: "overdue_invoice";
33
+ payment_failed: "payment_failed";
34
+ uncollectible: "uncollectible";
35
+ unpaid_invoice: "unpaid_invoice";
36
+ }>;
37
+ code: z.ZodEnum<{
38
+ BILLING_ACCOUNT_HOLD: "BILLING_ACCOUNT_HOLD";
39
+ BILLING_DISPUTE: "BILLING_DISPUTE";
40
+ BILLING_LINKED_UNPAID_BALANCE: "BILLING_LINKED_UNPAID_BALANCE";
41
+ BILLING_PAYMENT_METHOD_REQUIRED: "BILLING_PAYMENT_METHOD_REQUIRED";
42
+ BILLING_UNPAID_INVOICE: "BILLING_UNPAID_INVOICE";
43
+ }>;
44
+ message: z.ZodString;
45
+ linked: z.ZodBoolean;
46
+ paymentMethodRequired: z.ZodBoolean;
47
+ since: z.ZodDate;
48
+ blocking: z.ZodBoolean;
49
+ invoices: z.ZodArray<z.ZodObject<{
50
+ id: z.ZodString;
51
+ number: z.ZodNullable<z.ZodString>;
52
+ status: z.ZodString;
53
+ amountRemaining: z.ZodNumber;
54
+ currency: z.ZodString;
55
+ created: z.ZodNumber;
56
+ dueDate: z.ZodNullable<z.ZodNumber>;
57
+ attemptCount: z.ZodNumber;
58
+ nextPaymentAttempt: z.ZodNullable<z.ZodNumber>;
59
+ hostedInvoiceUrl: z.ZodNullable<z.ZodString>;
60
+ collectionMethod: z.ZodString;
61
+ }, z.core.$strip>>;
62
+ dispute: z.ZodNullable<z.ZodObject<{
63
+ id: z.ZodString;
64
+ status: z.ZodString;
65
+ amount: z.ZodNumber;
66
+ currency: z.ZodString;
67
+ reason: z.ZodString;
68
+ created: z.ZodNumber;
69
+ }, z.core.$strip>>;
70
+ }, z.core.$strip>>;
71
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
18
72
  //# sourceMappingURL=billing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../../../../lib/contract/gateway/router/billing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,eAAO,MAAM,MAAM;;2EAEC,CAAC;AAErB,eAAO,MAAM,MAAM;;;;;;;;;;;;0FAgBY,CAAC"}
1
+ {"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../../../../lib/contract/gateway/router/billing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,eAAO,MAAM,MAAM;;2EAEC,CAAC;AAErB,eAAO,MAAM,MAAM;;;;;;;;;;;;0FAgBY,CAAC;AAgBhC,mFAAmF;AACnF,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DAoChB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { oc } from "@orpc/contract";
2
2
  import * as z from "zod";
3
+ import { billingHoldErrorCodes } from "../../../billing-hold-error-codes.js";
3
4
  export const manage = oc
4
5
  .input(z.object({ returnURL: z.string() }))
5
6
  .output(z.string());
@@ -18,3 +19,52 @@ export const update = oc
18
19
  path: ["plan", "annual"],
19
20
  }))
20
21
  .output(z.string().optional());
22
+ const billingHoldInvoice = z.object({
23
+ id: z.string(),
24
+ number: z.string().nullable(),
25
+ status: z.string(),
26
+ amountRemaining: z.number(),
27
+ currency: z.string(),
28
+ created: z.number(),
29
+ dueDate: z.number().nullable(),
30
+ attemptCount: z.number(),
31
+ nextPaymentAttempt: z.number().nullable(),
32
+ hostedInvoiceUrl: z.string().nullable(),
33
+ collectionMethod: z.string(),
34
+ });
35
+ /** The workspace's billing hold (unpaid invoices or a payment dispute), if any. */
36
+ export const hold = oc.output(z.object({
37
+ mode: z.enum(["off", "shadow", "enforce"]),
38
+ hold: z
39
+ .object({
40
+ reason: z.enum([
41
+ "dispute",
42
+ "dispute_lost",
43
+ "uncollectible",
44
+ "payment_failed",
45
+ "unpaid_invoice",
46
+ "overdue_invoice",
47
+ "canceled_unpaid",
48
+ "linked_unpaid",
49
+ "manual",
50
+ ]),
51
+ code: z.enum(billingHoldErrorCodes),
52
+ message: z.string(),
53
+ linked: z.boolean(),
54
+ paymentMethodRequired: z.boolean(),
55
+ since: z.date(),
56
+ blocking: z.boolean(),
57
+ invoices: z.array(billingHoldInvoice),
58
+ dispute: z
59
+ .object({
60
+ id: z.string(),
61
+ status: z.string(),
62
+ amount: z.number(),
63
+ currency: z.string(),
64
+ reason: z.string(),
65
+ created: z.number(),
66
+ })
67
+ .nullable(),
68
+ })
69
+ .nullable(),
70
+ }));
@@ -1,4 +1,5 @@
1
1
  export * from "./api-source.js";
2
+ export * from "./billing-hold-error-codes.js";
2
3
  export * from "./date.js";
3
4
  export * from "./dedicated-instance-monthly-credits.js";
4
5
  export * from "./environment.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,sCAAsC,CAAC;AACrD,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,QAAQ,CAAC;AACvB,cAAc,sCAAsC,CAAC;AACrD,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC"}
package/.tsc/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./api-source.js";
2
+ export * from "./billing-hold-error-codes.js";
2
3
  export * from "./date.js";
3
4
  export * from "./dedicated-instance-monthly-credits.js";
4
5
  export * from "./environment.js";
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @pdfvector/util
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#507](https://github.com/phuctm97/pdfvector/pull/507) [`fbe51ca`](https://github.com/phuctm97/pdfvector/commit/fbe51ca228221c31d36565b14c284c1259ddcef1) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Billing holds: workspaces with unpaid invoices, payment disputes or a card/sign-in linked to another account's unpaid balance are blocked with HTTP 402 and a stable code (`BILLING_UNPAID_INVOICE`, `BILLING_DISPUTE`, `BILLING_PAYMENT_METHOD_REQUIRED`, `BILLING_LINKED_UNPAID_BALANCE`, `BILLING_ACCOUNT_HOLD`), cannot resubscribe until paid, and see their invoices with Pay buttons in billing. Out-of-credit errors now carry `CREDITS_EXHAUSTED`. Holds come from webhooks plus an hourly sweep, never from Stripe calls on the request path.
8
+
3
9
  ## 0.4.0
4
10
 
5
11
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfvector/util",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "main": "./.tsc/lib/index.js",
6
6
  "exports": {