@anuragpal02/zcl-contracts 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,22 @@
1
+ # @anuragpal02/zcl-contracts
2
+
3
+ Shared ZCL request/response contracts, Zod schemas, and typed API client.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @anuragpal02/zcl-contracts
9
+ ```
10
+
11
+ The package is public on npmjs.org for now, so consumers do not need a registry token to install it.
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { sessionResponseSchema } from '@anuragpal02/zcl-contracts'
17
+ import { createZclApiClient } from '@anuragpal02/zcl-contracts/client'
18
+ ```
19
+
20
+ ## Publish
21
+
22
+ Publishing is manual through the `Publish` GitHub Actions workflow. Bump `version` in `package.json`, merge to `main`, then run the workflow with `NPM_TOKEN` configured.
package/dist/auth.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ import { z } from 'zod';
2
+ export declare const signupRequestSchema: z.ZodObject<{
3
+ email: z.ZodString;
4
+ password: z.ZodString;
5
+ name: z.ZodString;
6
+ }, z.core.$strip>;
7
+ export declare const loginRequestSchema: z.ZodObject<{
8
+ email: z.ZodString;
9
+ password: z.ZodString;
10
+ }, z.core.$strip>;
11
+ export declare const sessionUserSchema: z.ZodObject<{
12
+ id: z.ZodString;
13
+ email: z.ZodString;
14
+ name: z.ZodNullable<z.ZodString>;
15
+ emailVerifiedAt: z.ZodNullable<z.ZodString>;
16
+ }, z.core.$strip>;
17
+ export declare const sessionResponseSchema: z.ZodObject<{
18
+ user: z.ZodNullable<z.ZodObject<{
19
+ id: z.ZodString;
20
+ email: z.ZodString;
21
+ name: z.ZodNullable<z.ZodString>;
22
+ emailVerifiedAt: z.ZodNullable<z.ZodString>;
23
+ }, z.core.$strip>>;
24
+ }, z.core.$strip>;
25
+ export declare const authSessionResponseSchema: z.ZodObject<{
26
+ user: z.ZodObject<{
27
+ id: z.ZodString;
28
+ email: z.ZodString;
29
+ name: z.ZodNullable<z.ZodString>;
30
+ emailVerifiedAt: z.ZodNullable<z.ZodString>;
31
+ }, z.core.$strip>;
32
+ }, z.core.$strip>;
33
+ export declare const logoutResponseSchema: z.ZodObject<{
34
+ ok: z.ZodLiteral<true>;
35
+ }, z.core.$strip>;
36
+ export type AuthSessionResponse = z.infer<typeof authSessionResponseSchema>;
37
+ export type LoginRequest = z.infer<typeof loginRequestSchema>;
38
+ export type LogoutResponse = z.infer<typeof logoutResponseSchema>;
39
+ export type SessionResponse = z.infer<typeof sessionResponseSchema>;
40
+ export type SessionUser = z.infer<typeof sessionUserSchema>;
41
+ export type SignupRequest = z.infer<typeof signupRequestSchema>;
42
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,mBAAmB;;;;iBAI9B,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;iBAG7B,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;iBAK5B,CAAA;AAEF,eAAO,MAAM,qBAAqB;;;;;;;iBAEhC,CAAA;AAEF,eAAO,MAAM,yBAAyB;;;;;;;iBAEpC,CAAA;AAEF,eAAO,MAAM,oBAAoB;;iBAE/B,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAC3E,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAC7D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACjE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AACnE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAC3D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
package/dist/auth.js ADDED
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { idSchema, isoDateSchema } from './common';
3
+ export const signupRequestSchema = z.object({
4
+ email: z.string().email(),
5
+ password: z.string().min(8).max(128),
6
+ name: z.string().min(1).max(120)
7
+ });
8
+ export const loginRequestSchema = z.object({
9
+ email: z.string().email(),
10
+ password: z.string().min(8).max(128)
11
+ });
12
+ export const sessionUserSchema = z.object({
13
+ id: idSchema,
14
+ email: z.string().email(),
15
+ name: z.string().nullable(),
16
+ emailVerifiedAt: isoDateSchema.nullable()
17
+ });
18
+ export const sessionResponseSchema = z.object({
19
+ user: sessionUserSchema.nullable()
20
+ });
21
+ export const authSessionResponseSchema = z.object({
22
+ user: sessionUserSchema
23
+ });
24
+ export const logoutResponseSchema = z.object({
25
+ ok: z.literal(true)
26
+ });
@@ -0,0 +1,42 @@
1
+ import { type AuthSessionResponse, type LoginRequest, type LogoutResponse, type SessionResponse, type SignupRequest } from './auth';
2
+ import { type ApiErrorCode } from './common';
3
+ import { type CreateWorkspaceRequest, type Workspace, type WorkspaceMembership } from './workspaces';
4
+ type FetchLike = (request: Request) => Promise<Response>;
5
+ export type ZclApiClientOptions = {
6
+ baseUrl: string;
7
+ fetch?: FetchLike;
8
+ };
9
+ export type WorkspaceWithMembership = Workspace & {
10
+ membership: WorkspaceMembership;
11
+ };
12
+ export type WorkspaceListResponse = {
13
+ data: WorkspaceWithMembership[];
14
+ pagination: {
15
+ nextCursor: string | null;
16
+ };
17
+ };
18
+ export declare class ZclApiError extends Error {
19
+ readonly code: ApiErrorCode;
20
+ readonly status: number;
21
+ readonly requestId?: string | undefined;
22
+ constructor(code: ApiErrorCode, message: string, status: number, requestId?: string | undefined);
23
+ }
24
+ export declare function createZclApiClient(options: ZclApiClientOptions): {
25
+ auth: {
26
+ signup(input: SignupRequest): Promise<AuthSessionResponse>;
27
+ login(input: LoginRequest): Promise<AuthSessionResponse>;
28
+ logout(): Promise<LogoutResponse>;
29
+ };
30
+ session: {
31
+ get(): Promise<SessionResponse>;
32
+ };
33
+ workspaces: {
34
+ list(): Promise<WorkspaceListResponse>;
35
+ create(input: CreateWorkspaceRequest): Promise<{
36
+ data: Workspace;
37
+ }>;
38
+ };
39
+ };
40
+ export type ZclApiClient = ReturnType<typeof createZclApiClient>;
41
+ export {};
42
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,QAAQ,CAAA;AACf,OAAO,EAA2C,KAAK,YAAY,EAAE,MAAM,UAAU,CAAA;AACrF,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,SAAS,EACd,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAA;AAErB,KAAK,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAExD,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG;IAChD,UAAU,EAAE,mBAAmB,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,uBAAuB,EAAE,CAAA;IAC/B,UAAU,EAAE;QACV,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAC1B,CAAA;CACF,CAAA;AAQD,qBAAa,WAAY,SAAQ,KAAK;aAElB,IAAI,EAAE,YAAY;aAElB,MAAM,EAAE,MAAM;aACd,SAAS,CAAC,EAAE,MAAM;gBAHlB,IAAI,EAAE,YAAY,EAClC,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,YAAA;CAKrC;AA8BD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB;;sBAkD3C,aAAa,GAAG,OAAO,CAAC,mBAAmB,CAAC;qBAM7C,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC;kBAM9C,OAAO,CAAC,cAAc,CAAC;;;eAK1B,OAAO,CAAC,eAAe,CAAC;;;gBAKvB,OAAO,CAAC,qBAAqB,CAAC;sBAGxB,sBAAsB,GAAG,OAAO,CAAC;YAAE,IAAI,EAAE,SAAS,CAAA;SAAE,CAAC;;EAQxE;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
package/dist/client.js ADDED
@@ -0,0 +1,106 @@
1
+ import { z } from 'zod';
2
+ import { authSessionResponseSchema, loginRequestSchema, logoutResponseSchema, sessionResponseSchema, signupRequestSchema } from './auth';
3
+ import { errorResponseSchema, listResponseSchema } from './common';
4
+ import { createWorkspaceRequestSchema, workspaceMembershipSchema, workspaceSchema } from './workspaces';
5
+ const workspaceListResponseSchema = listResponseSchema(workspaceSchema.extend({
6
+ membership: workspaceMembershipSchema
7
+ }));
8
+ export class ZclApiError extends Error {
9
+ code;
10
+ status;
11
+ requestId;
12
+ constructor(code, message, status, requestId) {
13
+ super(message);
14
+ this.code = code;
15
+ this.status = status;
16
+ this.requestId = requestId;
17
+ this.name = 'ZclApiError';
18
+ }
19
+ }
20
+ function joinUrl(baseUrl, path) {
21
+ return `${baseUrl.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`;
22
+ }
23
+ async function readJson(response) {
24
+ const text = await response.text();
25
+ if (!text) {
26
+ return null;
27
+ }
28
+ try {
29
+ return JSON.parse(text);
30
+ }
31
+ catch {
32
+ throw new ZclApiError('internal_error', 'API response was not valid JSON', response.status);
33
+ }
34
+ }
35
+ function parseResponse(schema, body, status) {
36
+ const result = schema.safeParse(body);
37
+ if (!result.success) {
38
+ throw new ZclApiError('internal_error', 'API response failed validation', status);
39
+ }
40
+ return result.data;
41
+ }
42
+ export function createZclApiClient(options) {
43
+ const fetcher = options.fetch ?? fetch;
44
+ async function request(path, schema, init = {}) {
45
+ const headers = new Headers(init.headers);
46
+ const { body: requestBody, ...requestInitBase } = init;
47
+ let body;
48
+ if (requestBody !== undefined) {
49
+ headers.set('content-type', 'application/json');
50
+ body = JSON.stringify(requestBody);
51
+ }
52
+ const requestInit = {
53
+ ...requestInitBase,
54
+ headers,
55
+ credentials: 'include'
56
+ };
57
+ if (body !== undefined) {
58
+ requestInit.body = body;
59
+ }
60
+ const response = await fetcher(new Request(joinUrl(options.baseUrl, path), requestInit));
61
+ const responseBody = await readJson(response);
62
+ if (!response.ok) {
63
+ const error = errorResponseSchema.safeParse(responseBody);
64
+ if (error.success) {
65
+ throw new ZclApiError(error.data.error.code, error.data.error.message, response.status, error.data.error.requestId);
66
+ }
67
+ throw new ZclApiError('internal_error', 'API request failed', response.status);
68
+ }
69
+ return parseResponse(schema, responseBody, response.status);
70
+ }
71
+ return {
72
+ auth: {
73
+ signup(input) {
74
+ return request('/auth/signup', authSessionResponseSchema, {
75
+ method: 'POST',
76
+ body: signupRequestSchema.parse(input)
77
+ });
78
+ },
79
+ login(input) {
80
+ return request('/auth/login', authSessionResponseSchema, {
81
+ method: 'POST',
82
+ body: loginRequestSchema.parse(input)
83
+ });
84
+ },
85
+ logout() {
86
+ return request('/auth/logout', logoutResponseSchema, { method: 'POST' });
87
+ }
88
+ },
89
+ session: {
90
+ get() {
91
+ return request('/session', sessionResponseSchema);
92
+ }
93
+ },
94
+ workspaces: {
95
+ list() {
96
+ return request('/workspaces', workspaceListResponseSchema);
97
+ },
98
+ create(input) {
99
+ return request('/workspaces', z.object({ data: workspaceSchema }), {
100
+ method: 'POST',
101
+ body: createWorkspaceRequestSchema.parse(input)
102
+ });
103
+ }
104
+ }
105
+ };
106
+ }
@@ -0,0 +1,43 @@
1
+ import { z } from 'zod';
2
+ export declare const idSchema: z.ZodString;
3
+ export declare const isoDateSchema: z.ZodString;
4
+ export declare const apiErrorCodeSchema: z.ZodEnum<{
5
+ bad_request: "bad_request";
6
+ unauthorized: "unauthorized";
7
+ forbidden: "forbidden";
8
+ conflict: "conflict";
9
+ not_found: "not_found";
10
+ validation_failed: "validation_failed";
11
+ internal_error: "internal_error";
12
+ }>;
13
+ export declare const errorResponseSchema: z.ZodObject<{
14
+ error: z.ZodObject<{
15
+ code: z.ZodEnum<{
16
+ bad_request: "bad_request";
17
+ unauthorized: "unauthorized";
18
+ forbidden: "forbidden";
19
+ conflict: "conflict";
20
+ not_found: "not_found";
21
+ validation_failed: "validation_failed";
22
+ internal_error: "internal_error";
23
+ }>;
24
+ message: z.ZodString;
25
+ requestId: z.ZodOptional<z.ZodString>;
26
+ }, z.core.$strip>;
27
+ }, z.core.$strip>;
28
+ export declare const paginationSchema: z.ZodObject<{
29
+ nextCursor: z.ZodNullable<z.ZodString>;
30
+ }, z.core.$strip>;
31
+ export declare function apiSuccessSchema<TSchema extends z.ZodType>(schema: TSchema): z.ZodObject<{
32
+ data: TSchema;
33
+ }, z.core.$strip>;
34
+ export declare function listResponseSchema<TSchema extends z.ZodType>(itemSchema: TSchema): z.ZodObject<{
35
+ data: z.ZodArray<TSchema>;
36
+ pagination: z.ZodObject<{
37
+ nextCursor: z.ZodNullable<z.ZodString>;
38
+ }, z.core.$strip>;
39
+ }, z.core.$strip>;
40
+ export type ApiErrorCode = z.infer<typeof apiErrorCodeSchema>;
41
+ export type ErrorResponse = z.infer<typeof errorResponseSchema>;
42
+ export type Pagination = z.infer<typeof paginationSchema>;
43
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,QAAQ,aAAoB,CAAA;AACzC,eAAO,MAAM,aAAa,aAAwB,CAAA;AAElD,eAAO,MAAM,kBAAkB;;;;;;;;EAQ7B,CAAA;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;iBAM9B,CAAA;AAEF,eAAO,MAAM,gBAAgB;;iBAE3B,CAAA;AAEF,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO;;kBAE1E;AAED,wBAAgB,kBAAkB,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO;;;;;kBAKhF;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAC7D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC/D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
package/dist/common.js ADDED
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ export const idSchema = z.string().uuid();
3
+ export const isoDateSchema = z.string().datetime();
4
+ export const apiErrorCodeSchema = z.enum([
5
+ 'bad_request',
6
+ 'unauthorized',
7
+ 'forbidden',
8
+ 'conflict',
9
+ 'not_found',
10
+ 'validation_failed',
11
+ 'internal_error'
12
+ ]);
13
+ export const errorResponseSchema = z.object({
14
+ error: z.object({
15
+ code: apiErrorCodeSchema,
16
+ message: z.string().min(1),
17
+ requestId: z.string().optional()
18
+ })
19
+ });
20
+ export const paginationSchema = z.object({
21
+ nextCursor: z.string().nullable()
22
+ });
23
+ export function apiSuccessSchema(schema) {
24
+ return z.object({ data: schema });
25
+ }
26
+ export function listResponseSchema(itemSchema) {
27
+ return z.object({
28
+ data: z.array(itemSchema),
29
+ pagination: paginationSchema
30
+ });
31
+ }
@@ -0,0 +1,6 @@
1
+ export * from './auth';
2
+ export * from './client';
3
+ export * from './common';
4
+ export * from './projects';
5
+ export * from './workspaces';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './auth';
2
+ export * from './client';
3
+ export * from './common';
4
+ export * from './projects';
5
+ export * from './workspaces';
@@ -0,0 +1,69 @@
1
+ import { z } from 'zod';
2
+ export declare const projectVisibilitySchema: z.ZodEnum<{
3
+ private: "private";
4
+ workspace: "workspace";
5
+ }>;
6
+ export declare const projectStatusSchema: z.ZodEnum<{
7
+ active: "active";
8
+ archived: "archived";
9
+ deleted: "deleted";
10
+ }>;
11
+ export declare const ledPanelSchema: z.ZodObject<{
12
+ id: z.ZodString;
13
+ name: z.ZodString;
14
+ width: z.ZodNumber;
15
+ height: z.ZodNumber;
16
+ x: z.ZodNumber;
17
+ y: z.ZodNumber;
18
+ }, z.core.$strip>;
19
+ export declare const ledMapSchema: z.ZodObject<{
20
+ version: z.ZodNumber;
21
+ panels: z.ZodArray<z.ZodObject<{
22
+ id: z.ZodString;
23
+ name: z.ZodString;
24
+ width: z.ZodNumber;
25
+ height: z.ZodNumber;
26
+ x: z.ZodNumber;
27
+ y: z.ZodNumber;
28
+ }, z.core.$strip>>;
29
+ bounds: z.ZodObject<{
30
+ minX: z.ZodNumber;
31
+ minY: z.ZodNumber;
32
+ maxX: z.ZodNumber;
33
+ maxY: z.ZodNumber;
34
+ width: z.ZodNumber;
35
+ height: z.ZodNumber;
36
+ aspectRatio: z.ZodNumber;
37
+ }, z.core.$strip>;
38
+ }, z.core.$strip>;
39
+ export declare const projectSchema: z.ZodObject<{
40
+ id: z.ZodString;
41
+ workspaceId: z.ZodString;
42
+ createdByUserId: z.ZodString;
43
+ name: z.ZodString;
44
+ visibility: z.ZodEnum<{
45
+ private: "private";
46
+ workspace: "workspace";
47
+ }>;
48
+ status: z.ZodEnum<{
49
+ active: "active";
50
+ archived: "archived";
51
+ deleted: "deleted";
52
+ }>;
53
+ createdAt: z.ZodString;
54
+ updatedAt: z.ZodString;
55
+ }, z.core.$strip>;
56
+ export declare const createProjectRequestSchema: z.ZodObject<{
57
+ name: z.ZodString;
58
+ visibility: z.ZodDefault<z.ZodEnum<{
59
+ private: "private";
60
+ workspace: "workspace";
61
+ }>>;
62
+ }, z.core.$strip>;
63
+ export type CreateProjectRequest = z.input<typeof createProjectRequestSchema>;
64
+ export type LedMap = z.infer<typeof ledMapSchema>;
65
+ export type LedPanel = z.infer<typeof ledPanelSchema>;
66
+ export type Project = z.infer<typeof projectSchema>;
67
+ export type ProjectStatus = z.infer<typeof projectStatusSchema>;
68
+ export type ProjectVisibility = z.infer<typeof projectVisibilitySchema>;
69
+ //# sourceMappingURL=projects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../src/projects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,uBAAuB;;;EAAmC,CAAA;AACvE,eAAO,MAAM,mBAAmB;;;;EAA4C,CAAA;AAE5E,eAAO,MAAM,cAAc;;;;;;;iBAOzB,CAAA;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;iBAYvB,CAAA;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;iBASxB,CAAA;AAEF,eAAO,MAAM,0BAA0B;;;;;;iBAGrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAC7E,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AACjD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AACrD,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AACnD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC/D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA"}
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ import { idSchema, isoDateSchema } from './common';
3
+ export const projectVisibilitySchema = z.enum(['private', 'workspace']);
4
+ export const projectStatusSchema = z.enum(['active', 'archived', 'deleted']);
5
+ export const ledPanelSchema = z.object({
6
+ id: z.string().min(1),
7
+ name: z.string().min(1),
8
+ width: z.number().int().positive(),
9
+ height: z.number().int().positive(),
10
+ x: z.number().int(),
11
+ y: z.number().int()
12
+ });
13
+ export const ledMapSchema = z.object({
14
+ version: z.number().int().nonnegative(),
15
+ panels: z.array(ledPanelSchema),
16
+ bounds: z.object({
17
+ minX: z.number(),
18
+ minY: z.number(),
19
+ maxX: z.number(),
20
+ maxY: z.number(),
21
+ width: z.number().positive(),
22
+ height: z.number().positive(),
23
+ aspectRatio: z.number().positive()
24
+ })
25
+ });
26
+ export const projectSchema = z.object({
27
+ id: idSchema,
28
+ workspaceId: idSchema,
29
+ createdByUserId: idSchema,
30
+ name: z.string().min(1),
31
+ visibility: projectVisibilitySchema,
32
+ status: projectStatusSchema,
33
+ createdAt: isoDateSchema,
34
+ updatedAt: isoDateSchema
35
+ });
36
+ export const createProjectRequestSchema = z.object({
37
+ name: z.string().min(1).max(120),
38
+ visibility: projectVisibilitySchema.default('private')
39
+ });
@@ -0,0 +1,53 @@
1
+ import { z } from 'zod';
2
+ export declare const workspaceTypeSchema: z.ZodEnum<{
3
+ personal: "personal";
4
+ organization: "organization";
5
+ }>;
6
+ export declare const workspaceRoleSchema: z.ZodEnum<{
7
+ owner: "owner";
8
+ admin: "admin";
9
+ artist: "artist";
10
+ viewer: "viewer";
11
+ }>;
12
+ export declare const workspaceMembershipStatusSchema: z.ZodEnum<{
13
+ active: "active";
14
+ invited: "invited";
15
+ disabled: "disabled";
16
+ }>;
17
+ export declare const workspaceSchema: z.ZodObject<{
18
+ id: z.ZodString;
19
+ type: z.ZodEnum<{
20
+ personal: "personal";
21
+ organization: "organization";
22
+ }>;
23
+ name: z.ZodString;
24
+ slug: z.ZodString;
25
+ createdAt: z.ZodString;
26
+ updatedAt: z.ZodString;
27
+ }, z.core.$strip>;
28
+ export declare const createWorkspaceRequestSchema: z.ZodObject<{
29
+ name: z.ZodString;
30
+ type: z.ZodDefault<z.ZodLiteral<"organization">>;
31
+ }, z.core.$strip>;
32
+ export declare const workspaceMembershipSchema: z.ZodObject<{
33
+ workspaceId: z.ZodString;
34
+ userId: z.ZodString;
35
+ role: z.ZodEnum<{
36
+ owner: "owner";
37
+ admin: "admin";
38
+ artist: "artist";
39
+ viewer: "viewer";
40
+ }>;
41
+ status: z.ZodEnum<{
42
+ active: "active";
43
+ invited: "invited";
44
+ disabled: "disabled";
45
+ }>;
46
+ }, z.core.$strip>;
47
+ export type CreateWorkspaceRequest = z.input<typeof createWorkspaceRequestSchema>;
48
+ export type Workspace = z.infer<typeof workspaceSchema>;
49
+ export type WorkspaceMembership = z.infer<typeof workspaceMembershipSchema>;
50
+ export type WorkspaceMembershipStatus = z.infer<typeof workspaceMembershipStatusSchema>;
51
+ export type WorkspaceRole = z.infer<typeof workspaceRoleSchema>;
52
+ export type WorkspaceType = z.infer<typeof workspaceTypeSchema>;
53
+ //# sourceMappingURL=workspaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../src/workspaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,mBAAmB;;;EAAuC,CAAA;AACvE,eAAO,MAAM,mBAAmB;;;;;EAAiD,CAAA;AACjF,eAAO,MAAM,+BAA+B;;;;EAA4C,CAAA;AAExF,eAAO,MAAM,eAAe;;;;;;;;;;iBAO1B,CAAA;AAEF,eAAO,MAAM,4BAA4B;;;iBAGvC,CAAA;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;iBAKpC,CAAA;AAEF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AACjF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AACvD,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAC3E,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;AACvF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC/D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import { idSchema, isoDateSchema } from './common';
3
+ export const workspaceTypeSchema = z.enum(['personal', 'organization']);
4
+ export const workspaceRoleSchema = z.enum(['owner', 'admin', 'artist', 'viewer']);
5
+ export const workspaceMembershipStatusSchema = z.enum(['active', 'invited', 'disabled']);
6
+ export const workspaceSchema = z.object({
7
+ id: idSchema,
8
+ type: workspaceTypeSchema,
9
+ name: z.string().min(1),
10
+ slug: z.string().min(1),
11
+ createdAt: isoDateSchema,
12
+ updatedAt: isoDateSchema
13
+ });
14
+ export const createWorkspaceRequestSchema = z.object({
15
+ name: z.string().min(1).max(120),
16
+ type: z.literal('organization').default('organization')
17
+ });
18
+ export const workspaceMembershipSchema = z.object({
19
+ workspaceId: idSchema,
20
+ userId: idSchema,
21
+ role: workspaceRoleSchema,
22
+ status: workspaceMembershipStatusSchema
23
+ });
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@anuragpal02/zcl-contracts",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./client": {
14
+ "types": "./dist/client.d.ts",
15
+ "import": "./dist/client.js"
16
+ }
17
+ },
18
+ "files": ["dist"],
19
+ "publishConfig": {
20
+ "access": "public",
21
+ "registry": "https://registry.npmjs.org/"
22
+ },
23
+ "scripts": {
24
+ "prebuild": "node -e \"fs.rmSync('dist', { recursive: true, force: true })\"",
25
+ "build": "tsc -p tsconfig.json",
26
+ "test": "vitest run",
27
+ "typecheck": "tsc -p tsconfig.json --noEmit"
28
+ },
29
+ "dependencies": {
30
+ "zod": "^4.2.0"
31
+ },
32
+ "devDependencies": {
33
+ "typescript": "^6.0.2",
34
+ "vitest": "^4.0.0"
35
+ }
36
+ }