@inkress/admin-sdk 1.0.0 → 1.1.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +213 -0
  2. package/README.md +1174 -87
  3. package/dist/client.d.ts +3 -3
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/data-mappings.d.ts +177 -0
  6. package/dist/data-mappings.d.ts.map +1 -0
  7. package/dist/index.d.ts +34 -4
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.esm.js +4166 -154
  10. package/dist/index.esm.js.map +1 -1
  11. package/dist/index.js +4203 -153
  12. package/dist/index.js.map +1 -1
  13. package/dist/resources/addresses.d.ts +58 -0
  14. package/dist/resources/addresses.d.ts.map +1 -0
  15. package/dist/resources/billing-plans.d.ts +32 -15
  16. package/dist/resources/billing-plans.d.ts.map +1 -1
  17. package/dist/resources/categories.d.ts +30 -20
  18. package/dist/resources/categories.d.ts.map +1 -1
  19. package/dist/resources/currencies.d.ts +41 -0
  20. package/dist/resources/currencies.d.ts.map +1 -0
  21. package/dist/resources/exchange-rates.d.ts +50 -0
  22. package/dist/resources/exchange-rates.d.ts.map +1 -0
  23. package/dist/resources/fees.d.ts +58 -0
  24. package/dist/resources/fees.d.ts.map +1 -0
  25. package/dist/resources/financial-accounts.d.ts +47 -0
  26. package/dist/resources/financial-accounts.d.ts.map +1 -0
  27. package/dist/resources/financial-requests.d.ts +51 -0
  28. package/dist/resources/financial-requests.d.ts.map +1 -0
  29. package/dist/resources/generics.d.ts +57 -0
  30. package/dist/resources/generics.d.ts.map +1 -0
  31. package/dist/resources/kyc.d.ts +118 -0
  32. package/dist/resources/kyc.d.ts.map +1 -0
  33. package/dist/resources/merchants.d.ts +52 -15
  34. package/dist/resources/merchants.d.ts.map +1 -1
  35. package/dist/resources/orders.d.ts +74 -2
  36. package/dist/resources/orders.d.ts.map +1 -1
  37. package/dist/resources/payment-links.d.ts +65 -0
  38. package/dist/resources/payment-links.d.ts.map +1 -0
  39. package/dist/resources/payment-methods.d.ts +48 -0
  40. package/dist/resources/payment-methods.d.ts.map +1 -0
  41. package/dist/resources/products.d.ts +62 -16
  42. package/dist/resources/products.d.ts.map +1 -1
  43. package/dist/resources/public.d.ts +27 -7
  44. package/dist/resources/public.d.ts.map +1 -1
  45. package/dist/resources/subscriptions.d.ts +86 -20
  46. package/dist/resources/subscriptions.d.ts.map +1 -1
  47. package/dist/resources/tokens.d.ts +62 -0
  48. package/dist/resources/tokens.d.ts.map +1 -0
  49. package/dist/resources/transaction-entries.d.ts +48 -0
  50. package/dist/resources/transaction-entries.d.ts.map +1 -0
  51. package/dist/resources/users.d.ts +43 -21
  52. package/dist/resources/users.d.ts.map +1 -1
  53. package/dist/resources/webhook-urls.d.ts +49 -0
  54. package/dist/resources/webhook-urls.d.ts.map +1 -0
  55. package/dist/types/resources.d.ts +1294 -0
  56. package/dist/types/resources.d.ts.map +1 -0
  57. package/dist/types.d.ts +1069 -197
  58. package/dist/types.d.ts.map +1 -1
  59. package/dist/utils/query-builders.d.ts +518 -0
  60. package/dist/utils/query-builders.d.ts.map +1 -0
  61. package/dist/utils/query-transformer.d.ts +123 -0
  62. package/dist/utils/query-transformer.d.ts.map +1 -0
  63. package/dist/utils/translators.d.ts +126 -0
  64. package/dist/utils/translators.d.ts.map +1 -0
  65. package/dist/utils/webhooks.d.ts +19 -4
  66. package/dist/utils/webhooks.d.ts.map +1 -1
  67. package/package.json +14 -4
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Type-Based Query System
3
+ *
4
+ * This module provides a clean, type-safe query API where users write intuitive queries
5
+ * and the SDK automatically transforms them into the Elixir-compatible format.
6
+ *
7
+ * Features:
8
+ * - Array values → _in suffix (id: [1,2,3] → id_in: [1,2,3])
9
+ * - Range objects → _min/_max suffixes (age: {min: 18, max: 65} → age_min: 18, age_max: 65)
10
+ * - String operations → contains. prefix (name: {contains: "john"} → "contains.name": "john")
11
+ * - Date operations → before./after./on. prefixes
12
+ * - JSON field operations → in_, not_, null_, not_null_ prefixes
13
+ * - Direct values → equality check (no transformation)
14
+ */
15
+ export type RangeQuery<T> = {
16
+ min?: T;
17
+ max?: T;
18
+ };
19
+ export type StringQuery = {
20
+ contains?: string;
21
+ };
22
+ export type DateQuery = {
23
+ before?: string;
24
+ after?: string;
25
+ on?: string;
26
+ min?: string;
27
+ max?: string;
28
+ };
29
+ export type JsonQueryParams = {
30
+ [key: string]: any | {
31
+ in?: any;
32
+ not?: any;
33
+ null?: boolean;
34
+ not_null?: boolean;
35
+ min?: any;
36
+ max?: any;
37
+ };
38
+ };
39
+ export type QueryParams<T> = {
40
+ [K in keyof T]?: any;
41
+ } & {
42
+ exclude?: string | number;
43
+ distinct?: string;
44
+ order_by?: string;
45
+ data?: JsonQueryParams;
46
+ page?: number;
47
+ page_size?: number;
48
+ per_page?: number;
49
+ limit?: number;
50
+ override_page?: string | boolean;
51
+ q?: string;
52
+ search?: string;
53
+ sort?: string;
54
+ order?: 'asc' | 'desc';
55
+ };
56
+ /**
57
+ * Runtime validation for query parameters
58
+ */
59
+ export declare function validateQueryParams<T>(query: any, fieldTypes?: Partial<Record<keyof T, 'string' | 'number' | 'boolean' | 'date' | 'array'>>): string[];
60
+ /**
61
+ * Transform a clean user query into Elixir-compatible format
62
+ */
63
+ export declare function transformQuery<T>(query: any): Record<string, any>;
64
+ /**
65
+ * Flatten the transformed query object for API consumption
66
+ */
67
+ export declare function flattenTransformedQuery(transformed: Record<string, any>): Record<string, any>;
68
+ /**
69
+ * Main function to transform and flatten a query in one step
70
+ * Handles translation of contextual strings to integers before transformation
71
+ */
72
+ export declare function processQuery<T>(query: any, fieldTypes?: Partial<Record<keyof T, 'string' | 'number' | 'boolean' | 'date' | 'array'>>, options?: {
73
+ validate?: boolean;
74
+ context?: string;
75
+ }): Record<string, any>;
76
+ /**
77
+ * Type-safe query builder for specific entity types
78
+ */
79
+ export declare class QueryBuilder<T> {
80
+ private query;
81
+ constructor(initialQuery?: any);
82
+ /**
83
+ * Add a field equality condition
84
+ */
85
+ where<K extends keyof T>(field: K, value: any): this;
86
+ /**
87
+ * Add a field IN condition (array of values)
88
+ */
89
+ whereIn<K extends keyof T>(field: K, values: any[]): this;
90
+ /**
91
+ * Add a range condition (min/max)
92
+ */
93
+ whereRange<K extends keyof T>(field: K, min?: any, max?: any): this;
94
+ /**
95
+ * Add a string contains condition
96
+ */
97
+ whereContains<K extends keyof T>(field: K, value: string): this;
98
+ /**
99
+ * Add a date range condition
100
+ */
101
+ whereDateRange<K extends keyof T>(field: K, after?: string, before?: string, on?: string): this;
102
+ /**
103
+ * Add pagination
104
+ */
105
+ paginate(page: number, pageSize: number): this;
106
+ /**
107
+ * Add ordering
108
+ */
109
+ orderBy(field: string, direction?: 'asc' | 'desc'): this;
110
+ /**
111
+ * Add general search
112
+ */
113
+ search(term: string): this;
114
+ /**
115
+ * Build and return the transformed query
116
+ */
117
+ build(): Record<string, any>;
118
+ /**
119
+ * Get the raw query (before transformation)
120
+ */
121
+ getRawQuery(): any;
122
+ }
123
+ //# sourceMappingURL=query-transformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-transformer.d.ts","sourceRoot":"","sources":["../../src/utils/query-transformer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,GAAG,CAAC,EAAE,CAAC,CAAC;CACT,CAAC;AAGF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAGF,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAA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,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAS/F;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAM9C;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,KAAK,GAAG,MAAc,GAAG,IAAI;IAK/D;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK1B;;OAEG;IACH,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAI5B;;OAEG;IACH,WAAW,IAAI,GAAG;CAGnB"}
@@ -0,0 +1,126 @@
1
+ import { mappings } from '../data-mappings';
2
+ export type FeeStructureKey = keyof typeof mappings.FeeStructure;
3
+ export type KindKey = keyof typeof mappings.Kind;
4
+ export type StatusKey = keyof typeof mappings.Status;
5
+ export type AccessKey = keyof typeof mappings.Access;
6
+ export type FeeStructureValue = typeof mappings.FeeStructure[FeeStructureKey];
7
+ export type KindValue = typeof mappings.Kind[KindKey];
8
+ export type StatusValue = typeof mappings.Status[StatusKey];
9
+ export type AccessValue = typeof mappings.Access[AccessKey];
10
+ /**
11
+ * Translation functions for Fee Structures
12
+ */
13
+ export declare const FeeStructureTranslator: {
14
+ /**
15
+ * Convert string to integer for API calls
16
+ */
17
+ toInteger(key: FeeStructureKey): FeeStructureValue;
18
+ /**
19
+ * Convert integer to string for user display
20
+ */
21
+ toString(value: FeeStructureValue): FeeStructureKey;
22
+ /**
23
+ * Get all available options as string keys
24
+ */
25
+ getOptions(): FeeStructureKey[];
26
+ };
27
+ /**
28
+ * Translation functions for Kinds with context-aware prefixing
29
+ */
30
+ export declare const KindTranslator: {
31
+ /**
32
+ * Convert string to integer for API calls
33
+ */
34
+ toInteger(key: KindKey): KindValue;
35
+ /**
36
+ * Convert string to integer with context prefix
37
+ */
38
+ toIntegerWithContext(key: string, context: string): KindValue;
39
+ /**
40
+ * Convert integer to string for user display
41
+ */
42
+ toString(value: KindValue): KindKey;
43
+ /**
44
+ * Convert integer to string and remove context prefix
45
+ */
46
+ toStringWithoutContext(value: KindValue, context: string): string;
47
+ /**
48
+ * Get all available options as string keys
49
+ */
50
+ getOptions(): KindKey[];
51
+ /**
52
+ * Get options filtered by prefix (e.g., 'order_', 'product_')
53
+ */
54
+ getOptionsByPrefix(prefix: string): KindKey[];
55
+ /**
56
+ * Get options without context prefix for a specific context
57
+ */
58
+ getContextualOptions(context: string): string[];
59
+ };
60
+ /**
61
+ * Translation functions for Statuses with context-aware prefixing
62
+ */
63
+ export declare const StatusTranslator: {
64
+ /**
65
+ * Convert string to integer for API calls
66
+ */
67
+ toInteger(key: StatusKey): StatusValue;
68
+ /**
69
+ * Convert string to integer with context prefix
70
+ */
71
+ toIntegerWithContext(key: string, context: string): StatusValue;
72
+ /**
73
+ * Convert integer to string for user display
74
+ */
75
+ toString(value: StatusValue): StatusKey;
76
+ /**
77
+ * Convert integer to string and remove context prefix
78
+ */
79
+ toStringWithoutContext(value: StatusValue, context: string): string;
80
+ /**
81
+ * Get all available options as string keys
82
+ */
83
+ getOptions(): StatusKey[];
84
+ /**
85
+ * Get options filtered by prefix (e.g., 'order_', 'product_', 'account_')
86
+ */
87
+ getOptionsByPrefix(prefix: string): StatusKey[];
88
+ /**
89
+ * Get options without context prefix for a specific context
90
+ */
91
+ getContextualOptions(context: string): string[];
92
+ };
93
+ /**
94
+ * Translation functions for Access levels
95
+ */
96
+ export declare const AccessTranslator: {
97
+ /**
98
+ * Convert string to integer for API calls
99
+ */
100
+ toInteger(key: AccessKey): AccessValue;
101
+ /**
102
+ * Convert integer to string for user display
103
+ */
104
+ toString(value: AccessValue): AccessKey;
105
+ /**
106
+ * Get all available options as string keys
107
+ */
108
+ getOptions(): AccessKey[];
109
+ };
110
+ /**
111
+ * Generic translator for any mapping
112
+ */
113
+ export declare const createTranslator: <T extends Record<string, number>>(mapping: T) => {
114
+ toInteger: (key: keyof T) => T[keyof T];
115
+ toString: (value: T[keyof T]) => keyof T;
116
+ getOptions: () => (keyof T)[];
117
+ };
118
+ /**
119
+ * Helper function to safely convert values with fallback
120
+ */
121
+ export declare const safeTranslate: {
122
+ feeStructureToString: (value: number) => FeeStructureKey | null;
123
+ kindToString: (value: number) => KindKey | null;
124
+ statusToString: (value: number) => StatusKey | null;
125
+ };
126
+ //# sourceMappingURL=translators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translators.d.ts","sourceRoot":"","sources":["../../src/utils/translators.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,QAAQ,CAAC,YAAY,CAAC;AACjE,MAAM,MAAM,OAAO,GAAG,MAAM,OAAO,QAAQ,CAAC,IAAI,CAAC;AACjD,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,QAAQ,CAAC,MAAM,CAAC;AACrD,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,QAAQ,CAAC,MAAM,CAAC;AAErD,MAAM,MAAM,iBAAiB,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;AAC9E,MAAM,MAAM,SAAS,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACtD,MAAM,MAAM,WAAW,GAAG,OAAO,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAC5D,MAAM,MAAM,WAAW,GAAG,OAAO,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAgB5D;;GAEG;AACH,eAAO,MAAM,sBAAsB;IACjC;;OAEG;mBACY,eAAe,GAAG,iBAAiB;IAIlD;;OAEG;oBACa,iBAAiB,GAAG,eAAe;IAQnD;;OAEG;kBACW,eAAe,EAAE;CAGhC,CAAC;AAEF;;GAEG;A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,GAAG,IAAI;4BAQrB,MAAM,KAAG,SAAS,GAAG,IAAI;CAOlD,CAAC"}
@@ -10,8 +10,22 @@ export interface WebhookVerificationOptions {
10
10
  export declare class WebhookUtils {
11
11
  /**
12
12
  * Verify webhook signature using HMAC SHA256
13
+ * Inkress webhooks use the format: crypto.mac(:hmac, :sha256, secret, body) |> Base.encode64()
14
+ * The signature is sent in the X-Inkress-Webhook-Signature header
13
15
  */
14
- static verifySignature(payload: string | any, signature: string, secret: string, options?: WebhookVerificationOptions): boolean;
16
+ static verifySignature(body: string, signature: string, secret: string): boolean;
17
+ /**
18
+ * Verify webhook from an HTTP request object
19
+ * Automatically extracts signature from headers and body from request
20
+ * Returns both verification status and body (since body can only be read once)
21
+ */
22
+ static verifyRequest(request: {
23
+ headers: Record<string, string | string[] | undefined>;
24
+ body: string | any;
25
+ }, secret: string): {
26
+ isValid: boolean;
27
+ body: string;
28
+ };
15
29
  /**
16
30
  * Parse and validate webhook payload
17
31
  */
@@ -19,11 +33,12 @@ export declare class WebhookUtils {
19
33
  /**
20
34
  * Verify and parse webhook payload in one step
21
35
  */
22
- static verifyAndParse(payload: string, signature: string, secret: string, options?: WebhookVerificationOptions): WebhookPayload;
36
+ static verifyAndParse(body: string, signature: string, secret: string): WebhookPayload;
23
37
  /**
24
38
  * Generate webhook signature for testing
39
+ * Matches Inkress signature generation: crypto.mac(:hmac, :sha256, secret, body) |> Base.encode64()
25
40
  */
26
- static generateSignature(payload: string, secret: string, timestamp?: number): string;
41
+ static generateSignature(body: string, secret: string): string;
27
42
  /**
28
43
  * Create a test webhook payload
29
44
  */
@@ -37,6 +52,6 @@ export declare class WebhookUtils {
37
52
  */
38
53
  static extractEventData<T = any>(payload: WebhookPayload): T;
39
54
  }
40
- export declare function createWebhookMiddleware(secret: string, options?: WebhookVerificationOptions): (req: any, res: any, next: any) => any;
55
+ export declare function createWebhookMiddleware(secret: string): (req: any, res: any, next: any) => any;
41
56
  export declare function isWebhookEvent(data: any): data is WebhookPayload;
42
57
  //# sourceMappingURL=webhooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/utils/webhooks.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,YAAY;IACvB;;OAEG;IACH,MAAM,CAAC,eAAe,CACpB,OAAO,EAAE,MAAM,GAAG,GAAG,EACrB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,0BAA+B,GACvC,OAAO;IAyCV;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc;IAcpD;;OAEG;IACH,MAAM,CAAC,cAAc,CACnB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,0BAA0B,GACnC,cAAc;IAQjB;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;IAYrF;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,cAAc;IAQ7D;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAoBnD;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,cAAc,GAAG,CAAC;CAG7D;AAGD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,0BAA0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EAAE,YAAY,GAAG,cAAc;IAQ7D;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAoBnD;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,cAAc,GAAG,CAAC;CAG7D;AAGD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,IAC5C,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG,SA2BtC;AAGD,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,cAAc,CAQhE"}
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@inkress/admin-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Official Inkress Commerce API SDK for JavaScript/TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "types": "dist/index.d.ts",
8
- "private": false,
9
8
  "type": "module",
10
9
  "exports": {
11
10
  ".": {
@@ -23,14 +22,17 @@
23
22
  ],
24
23
  "scripts": {
25
24
  "build": "rollup -c",
25
+ "build:clean": "npm run clean && npm run build",
26
26
  "dev": "rollup -c -w",
27
27
  "test": "jest",
28
28
  "test:watch": "jest --watch",
29
+ "test:coverage": "jest --coverage",
29
30
  "lint": "eslint src --ext .ts,.js",
30
31
  "lint:fix": "eslint src --ext .ts,.js --fix",
31
32
  "type-check": "tsc --noEmit",
32
33
  "clean": "rm -rf dist",
33
- "prepare": "npm run clean && npm run build"
34
+ "prepare": "npm run clean && npm run build",
35
+ "prepublishOnly": "npm run test && npm run lint && npm run type-check && npm run build:clean"
34
36
  },
35
37
  "keywords": [
36
38
  "inkress",
@@ -47,7 +49,15 @@
47
49
  "storefront",
48
50
  "orders",
49
51
  "products",
50
- "merchants"
52
+ "merchants",
53
+ "subscriptions",
54
+ "billing",
55
+ "type-safe",
56
+ "query-builder",
57
+ "contextual-api",
58
+ "financial",
59
+ "webhooks",
60
+ "fully-typed"
51
61
  ],
52
62
  "author": {
53
63
  "name": "Inkress",