@pocketstock/types 0.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.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @pocketstock/types
2
+
3
+ Shared contracts package for PocketStock repositories.
4
+
5
+ ## Release Policy
6
+
7
+ - Semver is required.
8
+ - Breaking contract changes require a major version bump.
9
+ - `pocketstock-api` and `pocketstock-mobile` must pin exact versions.
10
+
11
+ ## Publish
12
+
13
+ 1. Bump version (`npm version patch|minor|major`).
14
+ 2. Push commit and tag.
15
+ 3. CI publish workflow runs on `v*` tags.
16
+
17
+ ## Versioning Order
18
+
19
+ Always publish `@pocketstock/types` before updating consuming repos.
package/dist/api.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import type { PageInfo } from "./core.js";
2
+ export type ApiErrorCode = "BAD_REQUEST" | "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "CONFLICT" | "RATE_LIMITED" | "INTERNAL_ERROR";
3
+ export type ApiErrorEnvelope = {
4
+ error: {
5
+ code: ApiErrorCode;
6
+ message: string;
7
+ details?: Record<string, unknown>;
8
+ requestId?: string;
9
+ };
10
+ };
11
+ export type ApiSuccessEnvelope<T> = {
12
+ data: T;
13
+ requestId?: string;
14
+ };
15
+ export type ApiPaginatedEnvelope<T> = {
16
+ data: T[];
17
+ pageInfo: PageInfo;
18
+ requestId?: string;
19
+ };
20
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,cAAc,GACd,WAAW,GACX,WAAW,GACX,UAAU,GACV,cAAc,GACd,gBAAgB,CAAC;AAErB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE;QACL,IAAI,EAAE,YAAY,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAClC,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI;IAClC,IAAI,EAAE,CAAC,CAAC;IACR,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;IACpC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
package/dist/api.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":""}
package/dist/core.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ export type Brand<TValue, TName extends string> = TValue & {
2
+ readonly __brand: TName;
3
+ };
4
+ export type ShopId = Brand<string, "ShopId">;
5
+ export type UserId = Brand<string, "UserId">;
6
+ export type ProductId = Brand<string, "ProductId">;
7
+ export type SaleId = Brand<string, "SaleId">;
8
+ export type IsoDateTime = Brand<string, "IsoDateTime">;
9
+ export type CurrencyCode = "RWF" | "USD" | "KES" | "TZS" | "UGX";
10
+ export type Money = {
11
+ amountMinor: number;
12
+ currency: CurrencyCode;
13
+ };
14
+ export type Paging = {
15
+ page: number;
16
+ pageSize: number;
17
+ };
18
+ export type PageInfo = {
19
+ page: number;
20
+ pageSize: number;
21
+ total: number;
22
+ hasNextPage: boolean;
23
+ };
24
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,CAAC,MAAM,EAAE,KAAK,SAAS,MAAM,IAAI,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;AAEvF,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC7C,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC7C,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACnD,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE7C,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEvD,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAEjE,MAAM,MAAM,KAAK,GAAG;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC"}
package/dist/core.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export * from "./core.js";
2
+ export * from "./api.js";
3
+ export * from "./sync.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./core.js";
2
+ export * from "./api.js";
3
+ export * from "./sync.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
package/dist/sync.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import type { IsoDateTime } from "./core.js";
2
+ export type SyncOperationType = "CREATE" | "UPDATE" | "DELETE";
3
+ export type SyncEntityName = "shop" | "user" | "product" | "sale" | "unknown";
4
+ export type SyncOperation = {
5
+ operationId: string;
6
+ entityName: SyncEntityName;
7
+ entityId: string;
8
+ operationType: SyncOperationType;
9
+ payload: Record<string, unknown>;
10
+ occurredAt: IsoDateTime;
11
+ deviceId: string;
12
+ };
13
+ export type SyncPullRequest = {
14
+ sinceSequence: number;
15
+ limit?: number;
16
+ };
17
+ export type SyncPullResponse = {
18
+ nextSequence: number;
19
+ operations: SyncOperation[];
20
+ };
21
+ export type SyncPushRequest = {
22
+ operations: SyncOperation[];
23
+ };
24
+ export type SyncPushResponse = {
25
+ acceptedOperationIds: string[];
26
+ rejected: Array<{
27
+ operationId: string;
28
+ reason: string;
29
+ }>;
30
+ };
31
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE/D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAE9E,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,cAAc,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,iBAAiB,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,UAAU,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,QAAQ,EAAE,KAAK,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACJ,CAAC"}
package/dist/sync.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@pocketstock/types",
3
+ "version": "0.1.0",
4
+ "description": "Shared contracts for PocketStock mobile and API",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "type": "module",
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "engines": {
16
+ "node": ">=20"
17
+ },
18
+ "scripts": {
19
+ "clean": "rm -rf dist",
20
+ "build": "tsc -p tsconfig.build.json",
21
+ "typecheck": "tsc --noEmit -p tsconfig.json",
22
+ "lint": "tsc --noEmit -p tsconfig.json",
23
+ "test": "node --test"
24
+ },
25
+ "devDependencies": {
26
+ "typescript": "^5.6.3"
27
+ }
28
+ }