sinfactura-types 1.0.90 → 1.0.95
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/README.md +37 -11
- package/dist/audit.d.ts +35 -0
- package/dist/audit.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/order.d.ts +1 -0
- package/dist/return.d.ts +35 -0
- package/dist/return.js +1 -0
- package/dist/subscription.d.ts +147 -0
- package/dist/subscription.js +15 -0
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -1,24 +1,50 @@
|
|
|
1
1
|
# `sinfactura-types`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
updated
|
|
3
|
+
Shared TypeScript type definitions for the SINFACTURA platform. Published as the `sinfactura-types` npm package and consumed by the other SINFACTURA repositories (primarily `app` and `web`) to ensure the backend, admin UI, and storefront agree on the shape of every domain entity: users, stores, customers, products, orders, invoices, baskets, notifications, and more.
|
|
5
4
|
|
|
6
|
-
##
|
|
5
|
+
## About the SINFACTURA Platform
|
|
6
|
+
|
|
7
|
+
This repository is part of the SINFACTURA monorepo — an integrated e-commerce, electronic invoicing, and business management suite for the Argentine market.
|
|
8
|
+
|
|
9
|
+
| Repository | Purpose | Stack |
|
|
10
|
+
| -------------------------------------------------------- | ------------------------------------------------------- | ------------------------------ |
|
|
11
|
+
| [`api`](https://github.com/sinfactura/api) | Serverless backend — REST + WebSocket APIs | AWS CDK, Lambda, DynamoDB |
|
|
12
|
+
| [`app`](https://github.com/sinfactura/app) | B2B operations & admin platform (internal) | React 19 + Vite + MUI v7 |
|
|
13
|
+
| [`web`](https://github.com/sinfactura/web) | Customer-facing e-commerce storefront (TODOINSUMOS) | React 19 + Vite + MUI v7 |
|
|
14
|
+
| [`landing`](https://github.com/sinfactura/landing) | Marketing website (sinfactura.com) | React 19 + Vite + MUI v7 |
|
|
15
|
+
| [`cloudprint`](https://github.com/sinfactura/cloudprint) | Desktop print agent — receives print jobs via WebSocket | Electron 41 + Vite + SQLite |
|
|
16
|
+
| **`types`** _(this repo)_ | Shared TypeScript types | `sinfactura-types` npm package |
|
|
17
|
+
|
|
18
|
+
## Purpose
|
|
19
|
+
|
|
20
|
+
`sinfactura-types` is the single source of truth for cross-repo TypeScript interfaces. Rather than duplicating domain shapes (e.g. `User`, `Order`, `Invoice`) in each client, every consumer imports them from this package so that a change to a server-side contract propagates to all clients at build time.
|
|
21
|
+
|
|
22
|
+
The package contains only TypeScript type declarations — no runtime code. Zod schemas for validation stay co-located in the repos that need them (e.g. `app/` keeps its Zod schemas local; see the root `CLAUDE.md`).
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
7
25
|
|
|
8
|
-
```
|
|
26
|
+
```bash
|
|
27
|
+
# In a SINFACTURA consumer repo (app, web, etc.)
|
|
9
28
|
yarn add --dev sinfactura-types
|
|
10
|
-
npm install -d sinfactura-types
|
|
11
29
|
```
|
|
12
30
|
|
|
13
|
-
##
|
|
31
|
+
## Usage
|
|
14
32
|
|
|
15
|
-
|
|
33
|
+
```typescript
|
|
34
|
+
import type { IUser, IOrder, IInvoice, IProduct } from "sinfactura-types";
|
|
35
|
+
```
|
|
16
36
|
|
|
17
|
-
##
|
|
37
|
+
## Publishing a New Version
|
|
18
38
|
|
|
19
|
-
|
|
20
|
-
|
|
39
|
+
1. Bump the `version` field in `package.json` (follow semver)
|
|
40
|
+
2. Publish to npm:
|
|
21
41
|
|
|
42
|
+
```bash
|
|
22
43
|
yarn publish
|
|
23
|
-
|
|
24
44
|
```
|
|
45
|
+
|
|
46
|
+
3. In each consumer repo, bump the `sinfactura-types` dependency (e.g. `app` currently uses `^1.0.90`)
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
Proprietary — Copyright © 2025-2026 SINFACTURA LLC. All rights reserved.
|
package/dist/audit.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface OrderAudit {
|
|
3
|
+
storeId: string;
|
|
4
|
+
auditId: string;
|
|
5
|
+
orderId: string;
|
|
6
|
+
userId: string;
|
|
7
|
+
fullName?: string;
|
|
8
|
+
action: OrderAuditAction;
|
|
9
|
+
createdAt: number;
|
|
10
|
+
dated: number;
|
|
11
|
+
changes?: OrderAuditChange[];
|
|
12
|
+
itemChanges?: {
|
|
13
|
+
added: Partial<BasketItem>[];
|
|
14
|
+
removed: Partial<BasketItem>[];
|
|
15
|
+
modified: Array<{
|
|
16
|
+
productId: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
oldQuantity: number;
|
|
19
|
+
newQuantity: number;
|
|
20
|
+
oldPrice: number;
|
|
21
|
+
newPrice: number;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
oldTotal?: number;
|
|
25
|
+
newTotal?: number;
|
|
26
|
+
returnId?: string;
|
|
27
|
+
}
|
|
28
|
+
interface OrderAuditChange {
|
|
29
|
+
field: string;
|
|
30
|
+
oldValue: unknown;
|
|
31
|
+
newValue: unknown;
|
|
32
|
+
}
|
|
33
|
+
type OrderAuditAction = 'order_created' | 'order_edited' | 'order_ready' | 'order_delivered' | 'order_delivery_cancelled' | 'order_disabled' | 'order_enabled' | 'order_returned' | 'discount_changed' | 'payment_method_changed' | 'delivery_method_changed' | 'delivery_address_changed' | 'invoice_created' | 'credit_note_created';
|
|
34
|
+
}
|
|
35
|
+
export {};
|
package/dist/audit.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./account";
|
|
2
2
|
export * from "./afip";
|
|
3
3
|
export * from "./api";
|
|
4
|
+
export * from "./audit";
|
|
4
5
|
export * from "./auth";
|
|
5
6
|
export * from "./basket";
|
|
6
7
|
export * from "./brands";
|
|
@@ -14,8 +15,10 @@ export * from "./maintenance";
|
|
|
14
15
|
export * from "./notification";
|
|
15
16
|
export * from "./order";
|
|
16
17
|
export * from "./product";
|
|
18
|
+
export * from "./return";
|
|
17
19
|
export * from "./stock";
|
|
18
20
|
export * from "./store";
|
|
21
|
+
export * from "./subscription";
|
|
19
22
|
export * from "./supplier";
|
|
20
23
|
export * from "./user";
|
|
21
24
|
export * from "./whatsapp";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./account";
|
|
2
2
|
export * from "./afip";
|
|
3
3
|
export * from "./api";
|
|
4
|
+
export * from "./audit";
|
|
4
5
|
export * from "./auth";
|
|
5
6
|
export * from "./basket";
|
|
6
7
|
export * from "./brands";
|
|
@@ -14,8 +15,10 @@ export * from "./maintenance";
|
|
|
14
15
|
export * from "./notification";
|
|
15
16
|
export * from "./order";
|
|
16
17
|
export * from "./product";
|
|
18
|
+
export * from "./return";
|
|
17
19
|
export * from "./stock";
|
|
18
20
|
export * from "./store";
|
|
21
|
+
export * from "./subscription";
|
|
19
22
|
export * from "./supplier";
|
|
20
23
|
export * from "./user";
|
|
21
24
|
export * from "./whatsapp";
|
package/dist/order.d.ts
CHANGED
package/dist/return.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Return {
|
|
3
|
+
storeId: string;
|
|
4
|
+
returnId: string;
|
|
5
|
+
orderId: string;
|
|
6
|
+
customerId: string;
|
|
7
|
+
invoiceId?: string;
|
|
8
|
+
creditNoteId?: string;
|
|
9
|
+
items: ReturnItem[];
|
|
10
|
+
subtotal: number;
|
|
11
|
+
cost: number;
|
|
12
|
+
total: number;
|
|
13
|
+
reason: ReturnReason;
|
|
14
|
+
notes?: string;
|
|
15
|
+
userId: string;
|
|
16
|
+
emitCreditNote: boolean;
|
|
17
|
+
sendEmail: boolean;
|
|
18
|
+
creditNoteEmitted: boolean;
|
|
19
|
+
createdAt: number;
|
|
20
|
+
dated: number;
|
|
21
|
+
}
|
|
22
|
+
interface ReturnItem {
|
|
23
|
+
productId: string;
|
|
24
|
+
name: string;
|
|
25
|
+
sku?: string;
|
|
26
|
+
quantity: number;
|
|
27
|
+
price: number;
|
|
28
|
+
cost: number;
|
|
29
|
+
ivaType: number;
|
|
30
|
+
condition: 'sellable' | 'damaged';
|
|
31
|
+
restock: boolean;
|
|
32
|
+
}
|
|
33
|
+
type ReturnReason = 'defective' | 'wrong_item' | 'damaged_shipping' | 'customer_changed_mind' | 'not_as_described' | 'duplicate_order' | 'price_adjustment' | 'billing_error' | 'other';
|
|
34
|
+
}
|
|
35
|
+
export {};
|
package/dist/return.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subscription types — plan tiers, entitlements, feature matrix, subscription state.
|
|
3
|
+
*
|
|
4
|
+
* Ships app#710 (Chunk 1). Canonical decisions live in
|
|
5
|
+
* sinfactura/app/docs/plans/SUBSCRIPTION_BUSINESS_DECISIONS.md.
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* - Tier names are the 4 locked Spanish tiers (per SUBSCRIPTION_TIERS_BEST_PRACTICES §0).
|
|
9
|
+
* - `fundador` is a `SubscriptionStatus` on `negocio`-tier plans (ADR-0009).
|
|
10
|
+
* - `FeatureKey` uses flat camelCase (not the dotted `reports.advanced` from the design kit).
|
|
11
|
+
* - Monetary amounts are integers in minor units (ARS cents) to avoid float issues.
|
|
12
|
+
* - WhatsApp-specific feature keys + `customDomain` are intentionally OUT of scope here;
|
|
13
|
+
* they ship with their own epics (#1072, #1152) after Product sign-off.
|
|
14
|
+
*/
|
|
15
|
+
declare global {
|
|
16
|
+
type PlanTier = 'basico' | 'emprendedor' | 'negocio' | 'empresa';
|
|
17
|
+
/**
|
|
18
|
+
* Lifecycle status of a tenant's subscription.
|
|
19
|
+
*
|
|
20
|
+
* - `trialing` — new signup in the 30-day NEGOCIO trial (no payment method).
|
|
21
|
+
* - `active` — paid subscription, period current.
|
|
22
|
+
* - `past_due` — payment failed, in the 7-day grace window.
|
|
23
|
+
* - `readonly` — grace elapsed, writes blocked, tenant can still read.
|
|
24
|
+
* - `canceled` — tenant ended subscription; data retained per grace policy.
|
|
25
|
+
* - `fundador` — pre-launch cohort, 12-month free NEGOCIO entitlements (ADR-0009).
|
|
26
|
+
*/
|
|
27
|
+
type SubscriptionStatus = 'trialing' | 'active' | 'past_due' | 'readonly' | 'canceled' | 'fundador';
|
|
28
|
+
type BillingCycle = 'monthly' | 'annual';
|
|
29
|
+
/**
|
|
30
|
+
* Shape of a single entitlement on a (tier, feature) cell.
|
|
31
|
+
*
|
|
32
|
+
* - `boolean` — on/off gate. `enabled` is the only relevant field.
|
|
33
|
+
* - `numeric` — hard cap; `limit` required; block on overage.
|
|
34
|
+
* - `metered` — usage-tracked; `limit` required. At launch behaves the same as
|
|
35
|
+
* `numeric` (counter-based enforcement, no overage billing). Kept
|
|
36
|
+
* distinct so post-launch metered billing can flip behavior without
|
|
37
|
+
* a migration.
|
|
38
|
+
*/
|
|
39
|
+
type EntitlementType = 'boolean' | 'numeric' | 'metered';
|
|
40
|
+
interface Entitlement {
|
|
41
|
+
type: EntitlementType;
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
/** Required for `numeric` and `metered`. `Infinity`-equivalent — treat sentinel value for "unlimited". */
|
|
44
|
+
limit?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* All gated features. Add new keys here when a new feature becomes gateable;
|
|
48
|
+
* every existing plan in `FEATURE_MATRIX` must then declare the new key
|
|
49
|
+
* (TypeScript enforces this via `Record<FeatureKey, Entitlement>`).
|
|
50
|
+
*/
|
|
51
|
+
type FeatureKey = 'maxOrdersMonth' | 'maxInvoicesMonth' | 'maxProducts' | 'maxUsers' | 'maxCustomers' | 'maxStores' | 'afip' | 'stripePayments' | 'suppliers' | 'cash' | 'multiStore' | 'importExport' | 'reportsAdvanced' | 'customBranding' | 'apiAccess' | 'prioritySupport';
|
|
52
|
+
/** Full feature matrix — every tier declares every feature. */
|
|
53
|
+
type FeatureMatrix = Record<PlanTier, Record<FeatureKey, Entitlement>>;
|
|
54
|
+
/** Resolved entitlements for a specific tenant (matrix + overrides applied). */
|
|
55
|
+
type ResolvedEntitlements = Record<FeatureKey, Entitlement>;
|
|
56
|
+
/**
|
|
57
|
+
* A sellable plan in the catalog. Seeded into DynamoDB by api#626 and
|
|
58
|
+
* served to the frontend via GET /subscription/plans.
|
|
59
|
+
*
|
|
60
|
+
* Prices are integers in ARS cents (e.g. $40 000 = 4_000_000).
|
|
61
|
+
* `null` = "Contactar ventas" (EMPRESA, pre-unlock).
|
|
62
|
+
*/
|
|
63
|
+
interface Plan {
|
|
64
|
+
tier: PlanTier;
|
|
65
|
+
/** Display label — "BÁSICO", "EMPRENDEDOR", "NEGOCIO", "EMPRESA". */
|
|
66
|
+
label: string;
|
|
67
|
+
/** Short marketing tagline (Spanish). */
|
|
68
|
+
blurb?: string;
|
|
69
|
+
/** Price in ARS cents for monthly billing. `null` = contactar. */
|
|
70
|
+
priceMonthly: number | null;
|
|
71
|
+
/** Price in ARS cents for annual billing (total / 12; ~20% discount). `null` = contactar. */
|
|
72
|
+
priceAnnual: number | null;
|
|
73
|
+
/** 'ARS' at launch. Reserved for future multi-currency. */
|
|
74
|
+
currency: 'ARS';
|
|
75
|
+
/**
|
|
76
|
+
* Whether the plan is accepting new subscribers. Closed-cohort plans
|
|
77
|
+
* (e.g. Founders after 2026-05-31) set this to `false` without deleting
|
|
78
|
+
* the plan row.
|
|
79
|
+
*/
|
|
80
|
+
isActive: boolean;
|
|
81
|
+
/** Marked as the anchor / recommended tier on the pricing page. NEGOCIO at launch. */
|
|
82
|
+
isPopular?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Visibility on the public pricing page. EMPRESA = `false` until
|
|
85
|
+
* ≥2 Planned features ship (per SUBSCRIPTION_TIERS_BEST_PRACTICES §0).
|
|
86
|
+
*/
|
|
87
|
+
isPublic: boolean;
|
|
88
|
+
/** Stripe Price IDs once the plan is wired to Stripe Products (api#627). */
|
|
89
|
+
stripeMonthlyPriceId?: string;
|
|
90
|
+
stripeAnnualPriceId?: string;
|
|
91
|
+
/** Per-tier entitlement configuration. */
|
|
92
|
+
entitlements: Record<FeatureKey, Entitlement>;
|
|
93
|
+
createdAt: number;
|
|
94
|
+
updatedAt: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A tenant's current subscription row. One per `tenantId`.
|
|
98
|
+
* Stored in DynamoDB; mirrored to Stripe when `stripeSubscriptionId` is present.
|
|
99
|
+
*/
|
|
100
|
+
interface Subscription {
|
|
101
|
+
tenantId: string;
|
|
102
|
+
planTier: PlanTier;
|
|
103
|
+
status: SubscriptionStatus;
|
|
104
|
+
billingCycle: BillingCycle;
|
|
105
|
+
/** Current period window (Unix ms). */
|
|
106
|
+
currentPeriodStart: number;
|
|
107
|
+
currentPeriodEnd: number;
|
|
108
|
+
/** Set while `status === 'trialing'`. Unix ms. */
|
|
109
|
+
trialEndsAt?: number;
|
|
110
|
+
/** Set while `status === 'fundador'`. Unix ms. Per ADR-0009: 2027-06-30T00:00:00Z. */
|
|
111
|
+
freeUntil?: number;
|
|
112
|
+
/** Stripe identifiers (absent for trialing/fundador before checkout). */
|
|
113
|
+
stripeCustomerId?: string;
|
|
114
|
+
stripeSubscriptionId?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Per-tenant entitlement overrides (grandfathering). Applied on top of the
|
|
117
|
+
* plan's base entitlements when resolving.
|
|
118
|
+
*/
|
|
119
|
+
overrides?: Partial<Record<FeatureKey, Entitlement>>;
|
|
120
|
+
createdAt: number;
|
|
121
|
+
updatedAt: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Per-tenant, per-period usage counters for `metered` features. Monthly reset
|
|
125
|
+
* via scheduled Lambda (api#629). At launch, used only for local enforcement;
|
|
126
|
+
* not reported to Stripe Meter (metered billing is a post-launch concern).
|
|
127
|
+
*/
|
|
128
|
+
interface UsageCounters {
|
|
129
|
+
tenantId: string;
|
|
130
|
+
/** Period start (Unix ms). Aligns with `Subscription.currentPeriodStart`. */
|
|
131
|
+
periodStart: number;
|
|
132
|
+
periodEnd: number;
|
|
133
|
+
/** Counters keyed by the metered-feature FeatureKey. Keys default to 0 when absent. */
|
|
134
|
+
counters: Partial<Record<FeatureKey, number>>;
|
|
135
|
+
updatedAt: number;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Full subscription snapshot pushed to the frontend on subscription/entitlement
|
|
139
|
+
* changes. Consumers use this to invalidate RTK Query caches and re-render gates.
|
|
140
|
+
*/
|
|
141
|
+
interface SubscriptionSyncPayload {
|
|
142
|
+
subscription: Subscription;
|
|
143
|
+
entitlements: ResolvedEntitlements;
|
|
144
|
+
usage?: UsageCounters;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subscription types — plan tiers, entitlements, feature matrix, subscription state.
|
|
3
|
+
*
|
|
4
|
+
* Ships app#710 (Chunk 1). Canonical decisions live in
|
|
5
|
+
* sinfactura/app/docs/plans/SUBSCRIPTION_BUSINESS_DECISIONS.md.
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* - Tier names are the 4 locked Spanish tiers (per SUBSCRIPTION_TIERS_BEST_PRACTICES §0).
|
|
9
|
+
* - `fundador` is a `SubscriptionStatus` on `negocio`-tier plans (ADR-0009).
|
|
10
|
+
* - `FeatureKey` uses flat camelCase (not the dotted `reports.advanced` from the design kit).
|
|
11
|
+
* - Monetary amounts are integers in minor units (ARS cents) to avoid float issues.
|
|
12
|
+
* - WhatsApp-specific feature keys + `customDomain` are intentionally OUT of scope here;
|
|
13
|
+
* they ship with their own epics (#1072, #1152) after Product sign-off.
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sinfactura-types",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.95",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,7 +12,13 @@
|
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "tsc",
|
|
15
|
-
"prepublishOnly": "tsc"
|
|
15
|
+
"prepublishOnly": "tsc",
|
|
16
|
+
"login": "npm login",
|
|
17
|
+
"release": "npm version patch --no-git-tag-version && npm publish"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public",
|
|
21
|
+
"registry": "https://registry.npmjs.org/"
|
|
16
22
|
},
|
|
17
23
|
"repository": {
|
|
18
24
|
"type": "git",
|