@heavybit/ecommerce-contracts 0.2.3 → 0.3.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.
package/README.md CHANGED
@@ -6,7 +6,7 @@ The e-commerce app's own shared contracts (decision D40), built on the generic
6
6
  names and payload schemas — is defined here once. **No business logic** lives in this package, and
7
7
  nothing here may move into shared-lib (D39).
8
8
 
9
- Version **0.2.3** (0.2.2 is on the registry). 0.2.3 adds `auth.security.session_revoked` and the optional
9
+ Version **0.3.0** (0.2.3 is on the registry; 0.3.0 is unpublished until approved). 0.3.0 adds the permission catalogue (`PERMISSIONS`, `PermissionName`), `PLATFORM_COMPANY_ID` and `SUPER_ADMIN_ROLE_KEY` (CR-06-33). 0.2.3 added `auth.security.session_revoked` and the optional
10
10
  `revokedAt` (`auth.security.sessions_revoked`) and `authzVersion` (`auth.user.authz_changed`) fields (Prompt 4.5).
11
11
  Until a version is published, install the local build without saving it:
12
12
  `npm pack` here, then `npm install --no-save ../ecommerce-contracts/heavybit-ecommerce-contracts-<version>.tgz` in the service.
@@ -22,7 +22,7 @@ Prompt 1.10.
22
22
  | Identity (`identity.ts`) | `ecommerceIdentityProtocol`, `ecommerceStepUpScopes` |
23
23
  | Scopes (`scopes.ts`) | `companyScope`, `customerScope`, `platformScope`, `companyScopeFrom`, `isPlatformOperator`, `COMPANY_COLUMN`, `CUSTOMER_COLUMN`, `COMPANY_SCOPE_KEY`, `PLATFORM_PERMISSION_PREFIX` |
24
24
  | Bindings (`bindings.ts`) | `money`, `zeroMoney`, `normalisePhone`, `companyDayBounds`, `APPROVAL_TTL_HOURS`, `approvalPolicy`, `toAuditRecordedPayload`, `signAppSocketTicket`, `verifyAppSocketTicket`, `companyRoom`, `canJoinCompanyRoom` |
25
- | Permissions (`permissions.ts`) | `APPROVAL_DECIDE_PERMISSION` |
25
+ | Permissions (`permissions.ts`) | `PERMISSIONS`, `PermissionName`, `APPROVAL_DECIDE_PERMISSION`, `PLATFORM_COMPANY_ID`, `SUPER_ADMIN_ROLE_KEY` |
26
26
  | Events (`events/`) | `ROUTING_KEYS`, `ALL_ROUTING_KEYS`, `schemaFor`, `envelopeDataSchemaFor`, `isRoutingKey`, `isCompanyScopedEvent`, `EVENT_SCHEMAS`, `COMMAND_SCHEMAS`, `MESSAGE_SCHEMAS`, `EVENT_EXCHANGE`, `COMMAND_EXCHANGE`, `EVENT_PUBLISHERS`, `auditRecordedSchema`, audit/socket-rejected keys and binding patterns; types `EventPayload<K>`, `EventPayloadInput<K>` |
27
27
 
28
28
  ## Commands
@@ -1,10 +1,59 @@
1
1
  "use strict";
2
2
  /**
3
- * E-commerce permission names (D40). Phases 4 and 6 add the full catalogue here (and seed it in
4
- * auth-admin-service); services import names from this module instead of writing literals.
3
+ * E-commerce permission catalogue and platform constants (D40, CR-06-33). Auth-admin-service seeds these names
4
+ * (`seeds/data/rbac-catalogue.json` must equal this list); every service imports names from here, never literals.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.APPROVAL_DECIDE_PERMISSION = void 0;
7
+ exports.PERMISSIONS = exports.APPROVAL_DECIDE_PERMISSION = exports.SUPER_ADMIN_ROLE_KEY = exports.PLATFORM_COMPANY_ID = void 0;
8
+ /** Id of the platform company (D7, D8): the tenant whose members hold platform roles. */
9
+ exports.PLATFORM_COMPANY_ID = '00000000000000000000000001';
10
+ /** Key of the platform role that always holds every permission. */
11
+ exports.SUPER_ADMIN_ROLE_KEY = 'super_admin';
8
12
  /** Held by anyone who may approve or reject two-person approval requests (§7.4), on top of the operation's own permission. */
9
13
  exports.APPROVAL_DECIDE_PERMISSION = 'approval:decide';
14
+ /** Every permission name in the catalogue, by camel-case key. */
15
+ exports.PERMISSIONS = {
16
+ dashboardRead: 'dashboard:read',
17
+ dashboardRevenue: 'dashboard:revenue',
18
+ companyRead: 'company:read',
19
+ companyUpdate: 'company:update',
20
+ themeManage: 'theme:manage',
21
+ domainManage: 'domain:manage',
22
+ productRead: 'product:read',
23
+ productWrite: 'product:write',
24
+ categoryWrite: 'category:write',
25
+ inventoryRead: 'inventory:read',
26
+ inventoryAdjust: 'inventory:adjust',
27
+ orderRead: 'order:read',
28
+ orderCreate: 'order:create',
29
+ orderUpdateStatus: 'order:update_status',
30
+ orderCancel: 'order:cancel',
31
+ paymentRecord: 'payment:record',
32
+ refundCreate: 'refund:create',
33
+ shipmentWrite: 'shipment:write',
34
+ deliveryManage: 'delivery:manage',
35
+ customerRead: 'customer:read',
36
+ issueRespond: 'issue:respond',
37
+ returnManage: 'return:manage',
38
+ reviewModerate: 'review:moderate',
39
+ discountWrite: 'discount:write',
40
+ integrationManage: 'integration:manage',
41
+ staffRead: 'staff:read',
42
+ staffManage: 'staff:manage',
43
+ roleManage: 'role:manage',
44
+ approvalDecide: 'approval:decide',
45
+ billingRead: 'billing:read',
46
+ billingManage: 'billing:manage',
47
+ reportRead: 'report:read',
48
+ auditRead: 'audit:read',
49
+ platformDashboard: 'platform:dashboard',
50
+ platformCompanyRead: 'platform:company:read',
51
+ platformCompanySuspend: 'platform:company:suspend',
52
+ platformUserRead: 'platform:user:read',
53
+ platformStaffManage: 'platform:staff:manage',
54
+ platformBillingRead: 'platform:billing:read',
55
+ platformBillingManage: 'platform:billing:manage',
56
+ platformDeliveryManage: 'platform:delivery:manage',
57
+ platformAuditRead: 'platform:audit:read',
58
+ };
10
59
  //# sourceMappingURL=permissions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/permissions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,8HAA8H;AACjH,QAAA,0BAA0B,GAAG,iBAA0B,CAAC"}
1
+ {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/permissions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yFAAyF;AAC5E,QAAA,mBAAmB,GAAG,4BAAqC,CAAC;AAEzE,mEAAmE;AACtD,QAAA,oBAAoB,GAAG,aAAsB,CAAC;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"}
@@ -1,7 +1,56 @@
1
1
  /**
2
- * E-commerce permission names (D40). Phases 4 and 6 add the full catalogue here (and seed it in
3
- * auth-admin-service); services import names from this module instead of writing literals.
2
+ * E-commerce permission catalogue and platform constants (D40, CR-06-33). Auth-admin-service seeds these names
3
+ * (`seeds/data/rbac-catalogue.json` must equal this list); every service imports names from here, never literals.
4
4
  */
5
+ /** Id of the platform company (D7, D8): the tenant whose members hold platform roles. */
6
+ export const PLATFORM_COMPANY_ID = '00000000000000000000000001';
7
+ /** Key of the platform role that always holds every permission. */
8
+ export const SUPER_ADMIN_ROLE_KEY = 'super_admin';
5
9
  /** Held by anyone who may approve or reject two-person approval requests (§7.4), on top of the operation's own permission. */
6
10
  export const APPROVAL_DECIDE_PERMISSION = 'approval:decide';
11
+ /** Every permission name in the catalogue, by camel-case key. */
12
+ export const PERMISSIONS = {
13
+ dashboardRead: 'dashboard:read',
14
+ dashboardRevenue: 'dashboard:revenue',
15
+ companyRead: 'company:read',
16
+ companyUpdate: 'company:update',
17
+ themeManage: 'theme:manage',
18
+ domainManage: 'domain:manage',
19
+ productRead: 'product:read',
20
+ productWrite: 'product:write',
21
+ categoryWrite: 'category:write',
22
+ inventoryRead: 'inventory:read',
23
+ inventoryAdjust: 'inventory:adjust',
24
+ orderRead: 'order:read',
25
+ orderCreate: 'order:create',
26
+ orderUpdateStatus: 'order:update_status',
27
+ orderCancel: 'order:cancel',
28
+ paymentRecord: 'payment:record',
29
+ refundCreate: 'refund:create',
30
+ shipmentWrite: 'shipment:write',
31
+ deliveryManage: 'delivery:manage',
32
+ customerRead: 'customer:read',
33
+ issueRespond: 'issue:respond',
34
+ returnManage: 'return:manage',
35
+ reviewModerate: 'review:moderate',
36
+ discountWrite: 'discount:write',
37
+ integrationManage: 'integration:manage',
38
+ staffRead: 'staff:read',
39
+ staffManage: 'staff:manage',
40
+ roleManage: 'role:manage',
41
+ approvalDecide: 'approval:decide',
42
+ billingRead: 'billing:read',
43
+ billingManage: 'billing:manage',
44
+ reportRead: 'report:read',
45
+ auditRead: 'audit:read',
46
+ platformDashboard: 'platform:dashboard',
47
+ platformCompanyRead: 'platform:company:read',
48
+ platformCompanySuspend: 'platform:company:suspend',
49
+ platformUserRead: 'platform:user:read',
50
+ platformStaffManage: 'platform:staff:manage',
51
+ platformBillingRead: 'platform:billing:read',
52
+ platformBillingManage: 'platform:billing:manage',
53
+ platformDeliveryManage: 'platform:delivery:manage',
54
+ platformAuditRead: 'platform:audit:read',
55
+ };
7
56
  //# sourceMappingURL=permissions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/permissions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8HAA8H;AAC9H,MAAM,CAAC,MAAM,0BAA0B,GAAG,iBAA0B,CAAC"}
1
+ {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/permissions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,yFAAyF;AACzF,MAAM,CAAC,MAAM,mBAAmB,GAAG,4BAAqC,CAAC;AAEzE,mEAAmE;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAsB,CAAC;AAE3D,8HAA8H;AAC9H,MAAM,CAAC,MAAM,0BAA0B,GAAG,iBAA0B,CAAC;AAErE,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,aAAa,EAAE,gBAAgB;IAC/B,gBAAgB,EAAE,mBAAmB;IACrC,WAAW,EAAE,cAAc;IAC3B,aAAa,EAAE,gBAAgB;IAC/B,WAAW,EAAE,cAAc;IAC3B,YAAY,EAAE,eAAe;IAC7B,WAAW,EAAE,cAAc;IAC3B,YAAY,EAAE,eAAe;IAC7B,aAAa,EAAE,gBAAgB;IAC/B,aAAa,EAAE,gBAAgB;IAC/B,eAAe,EAAE,kBAAkB;IACnC,SAAS,EAAE,YAAY;IACvB,WAAW,EAAE,cAAc;IAC3B,iBAAiB,EAAE,qBAAqB;IACxC,WAAW,EAAE,cAAc;IAC3B,aAAa,EAAE,gBAAgB;IAC/B,YAAY,EAAE,eAAe;IAC7B,aAAa,EAAE,gBAAgB;IAC/B,cAAc,EAAE,iBAAiB;IACjC,YAAY,EAAE,eAAe;IAC7B,YAAY,EAAE,eAAe;IAC7B,YAAY,EAAE,eAAe;IAC7B,cAAc,EAAE,iBAAiB;IACjC,aAAa,EAAE,gBAAgB;IAC/B,iBAAiB,EAAE,oBAAoB;IACvC,SAAS,EAAE,YAAY;IACvB,WAAW,EAAE,cAAc;IAC3B,UAAU,EAAE,aAAa;IACzB,cAAc,EAAE,iBAAiB;IACjC,WAAW,EAAE,cAAc;IAC3B,aAAa,EAAE,gBAAgB;IAC/B,UAAU,EAAE,aAAa;IACzB,SAAS,EAAE,YAAY;IACvB,iBAAiB,EAAE,oBAAoB;IACvC,mBAAmB,EAAE,uBAAuB;IAC5C,sBAAsB,EAAE,0BAA0B;IAClD,gBAAgB,EAAE,oBAAoB;IACtC,mBAAmB,EAAE,uBAAuB;IAC5C,mBAAmB,EAAE,uBAAuB;IAC5C,qBAAqB,EAAE,yBAAyB;IAChD,sBAAsB,EAAE,0BAA0B;IAClD,iBAAiB,EAAE,qBAAqB;CAChC,CAAC"}
@@ -1,7 +1,57 @@
1
1
  /**
2
- * E-commerce permission names (D40). Phases 4 and 6 add the full catalogue here (and seed it in
3
- * auth-admin-service); services import names from this module instead of writing literals.
2
+ * E-commerce permission catalogue and platform constants (D40, CR-06-33). Auth-admin-service seeds these names
3
+ * (`seeds/data/rbac-catalogue.json` must equal this list); every service imports names from here, never literals.
4
4
  */
5
+ /** Id of the platform company (D7, D8): the tenant whose members hold platform roles. */
6
+ export declare const PLATFORM_COMPANY_ID: "00000000000000000000000001";
7
+ /** Key of the platform role that always holds every permission. */
8
+ export declare const SUPER_ADMIN_ROLE_KEY: "super_admin";
5
9
  /** Held by anyone who may approve or reject two-person approval requests (§7.4), on top of the operation's own permission. */
6
10
  export declare const APPROVAL_DECIDE_PERMISSION: "approval:decide";
11
+ /** Every permission name in the catalogue, by camel-case key. */
12
+ export declare const PERMISSIONS: {
13
+ readonly dashboardRead: "dashboard:read";
14
+ readonly dashboardRevenue: "dashboard:revenue";
15
+ readonly companyRead: "company:read";
16
+ readonly companyUpdate: "company:update";
17
+ readonly themeManage: "theme:manage";
18
+ readonly domainManage: "domain:manage";
19
+ readonly productRead: "product:read";
20
+ readonly productWrite: "product:write";
21
+ readonly categoryWrite: "category:write";
22
+ readonly inventoryRead: "inventory:read";
23
+ readonly inventoryAdjust: "inventory:adjust";
24
+ readonly orderRead: "order:read";
25
+ readonly orderCreate: "order:create";
26
+ readonly orderUpdateStatus: "order:update_status";
27
+ readonly orderCancel: "order:cancel";
28
+ readonly paymentRecord: "payment:record";
29
+ readonly refundCreate: "refund:create";
30
+ readonly shipmentWrite: "shipment:write";
31
+ readonly deliveryManage: "delivery:manage";
32
+ readonly customerRead: "customer:read";
33
+ readonly issueRespond: "issue:respond";
34
+ readonly returnManage: "return:manage";
35
+ readonly reviewModerate: "review:moderate";
36
+ readonly discountWrite: "discount:write";
37
+ readonly integrationManage: "integration:manage";
38
+ readonly staffRead: "staff:read";
39
+ readonly staffManage: "staff:manage";
40
+ readonly roleManage: "role:manage";
41
+ readonly approvalDecide: "approval:decide";
42
+ readonly billingRead: "billing:read";
43
+ readonly billingManage: "billing:manage";
44
+ readonly reportRead: "report:read";
45
+ readonly auditRead: "audit:read";
46
+ readonly platformDashboard: "platform:dashboard";
47
+ readonly platformCompanyRead: "platform:company:read";
48
+ readonly platformCompanySuspend: "platform:company:suspend";
49
+ readonly platformUserRead: "platform:user:read";
50
+ readonly platformStaffManage: "platform:staff:manage";
51
+ readonly platformBillingRead: "platform:billing:read";
52
+ readonly platformBillingManage: "platform:billing:manage";
53
+ readonly platformDeliveryManage: "platform:delivery:manage";
54
+ readonly platformAuditRead: "platform:audit:read";
55
+ };
56
+ export type PermissionName = (typeof PERMISSIONS)[keyof typeof PERMISSIONS];
7
57
  //# sourceMappingURL=permissions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/permissions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8HAA8H;AAC9H,eAAO,MAAM,0BAA0B,EAAG,iBAA0B,CAAC"}
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/permissions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,yFAAyF;AACzF,eAAO,MAAM,mBAAmB,EAAG,4BAAqC,CAAC;AAEzE,mEAAmE;AACnE,eAAO,MAAM,oBAAoB,EAAG,aAAsB,CAAC;AAE3D,8HAA8H;AAC9H,eAAO,MAAM,0BAA0B,EAAG,iBAA0B,CAAC;AAErE,iEAAiE;AACjE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Cd,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heavybit/ecommerce-contracts",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "The e-commerce app's shared contracts: app settings, identity and scope bindings, step-up scopes, event catalogue and v1 payload schemas. Built on @heavybit/shared-lib; no business logic.",
5
5
  "license": "MIT",
6
6
  "type": "module",