minutework 0.1.34 → 0.1.36
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/EXTERNAL_ALPHA.md +8 -6
- package/README.md +1 -1
- package/assets/claude-local/CLAUDE.md.template +12 -8
- package/assets/templates/mobile-app/package.json +1 -0
- package/assets/templates/mobile-app/src/mw/client.ts +29 -232
- package/assets/templates/mobile-app/src/mw/session.ts +6 -2
- package/assets/templates/next-tenant-app/.env.example +2 -8
- package/assets/templates/next-tenant-app/README.md +4 -0
- package/assets/templates/next-tenant-app/src/app/app/demo/page.tsx +1 -7
- package/assets/templates/next-tenant-app/src/app/app/layout.tsx +9 -1
- package/assets/templates/next-tenant-app/src/features/shell/components/authenticated-app-layout-shell.tsx +181 -0
- package/assets/templates/next-tenant-app/src/features/shell/components/private-app-shell.tsx +3 -113
- package/assets/templates/next-tenant-app/src/mw/mock.test.ts +2 -1
- package/assets/templates/next-tenant-app/src/mw/mock.ts +3 -1
- package/assets/templates/next-tenant-app/tools/template/validate-route-contract.mjs +120 -1
- package/assets/templates/next-tenant-app/tools/template/with-public-site-fixture.mjs +28 -114
- package/assets/templates/next-tenant-app/vitest.config.ts +2 -6
- package/dist/runtime-package.d.ts +2 -1
- package/dist/runtime-package.js +12 -4
- package/dist/runtime-package.js.map +1 -1
- package/dist/workspace-bootstrap.js +2 -5
- package/dist/workspace-bootstrap.js.map +1 -1
- package/package.json +1 -1
- package/vendor/workspace-mcp/types.d.ts +27 -0
- package/assets/templates/mobile-app/src/mw/contracts.ts +0 -79
- package/assets/templates/mobile-app/src/mw/endpoints.ts +0 -42
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// MinuteWork substrate. Thin layer — do not put product UI/logic here.
|
|
2
|
-
//
|
|
3
|
-
// Zod schemas for the MinuteWork platform *native* session payloads. These match
|
|
4
|
-
// the SHIPPED platform native-token slice (`/api/v1/native/session/*`) response
|
|
5
|
-
// shapes exactly (DRF emits snake_case). They describe API responses, not product
|
|
6
|
-
// data. Keep them aligned with the platform serializers in
|
|
7
|
-
// `apps/mwv3-platform-dj/apps/gateway_api/serializers.py`:
|
|
8
|
-
// - token pair -> IssuedNativeAppSessionTokenPairSerializer
|
|
9
|
-
// - session/me -> TenantSessionResponseSerializer
|
|
10
|
-
//
|
|
11
|
-
// Schemas use `.passthrough()` so additive platform fields never break parsing;
|
|
12
|
-
// the client only depends on the fields it reads.
|
|
13
|
-
|
|
14
|
-
import { z } from "zod";
|
|
15
|
-
|
|
16
|
-
// A tenant the authenticated user belongs to. Mirrors `_serialize_membership`
|
|
17
|
-
// on the platform; only the load-bearing fields are constrained, the rest pass
|
|
18
|
-
// through. `role` may be an empty string for a membership with no role.
|
|
19
|
-
export const nativeMembershipSchema = z
|
|
20
|
-
.object({
|
|
21
|
-
tenant_id: z.string().min(1),
|
|
22
|
-
tenant_slug: z.string(),
|
|
23
|
-
tenant_name: z.string(),
|
|
24
|
-
role: z.string(),
|
|
25
|
-
})
|
|
26
|
-
.passthrough();
|
|
27
|
-
|
|
28
|
-
export const nativeActiveTenantSchema = nativeMembershipSchema;
|
|
29
|
-
|
|
30
|
-
// Mirrors `_serialize_user`. `email` is not constrained to an email shape because
|
|
31
|
-
// the platform may serialize a blank/non-email value.
|
|
32
|
-
export const nativeUserSchema = z
|
|
33
|
-
.object({
|
|
34
|
-
id: z.string().min(1),
|
|
35
|
-
username: z.string(),
|
|
36
|
-
email: z.string(),
|
|
37
|
-
})
|
|
38
|
-
.passthrough();
|
|
39
|
-
|
|
40
|
-
// Response of `/api/v1/native/session/me/` (and `/context/`):
|
|
41
|
-
// `TenantSessionResponseSerializer`. `active_tenant_id` / `active_tenant` are
|
|
42
|
-
// null when the user has no active membership.
|
|
43
|
-
export const nativeSessionSchema = z
|
|
44
|
-
.object({
|
|
45
|
-
user: nativeUserSchema,
|
|
46
|
-
active_tenant_id: z.string().nullable(),
|
|
47
|
-
active_tenant: nativeActiveTenantSchema.nullable(),
|
|
48
|
-
memberships: z.array(nativeMembershipSchema),
|
|
49
|
-
onboarding_completed_for_active_workspace: z.boolean().nullable().optional(),
|
|
50
|
-
})
|
|
51
|
-
.passthrough();
|
|
52
|
-
|
|
53
|
-
// Platform-issued bearer token pair returned by `/token-exchange/` and
|
|
54
|
-
// `/refresh/`: `IssuedNativeAppSessionTokenPairSerializer`. `*_expires_at` are
|
|
55
|
-
// ISO-8601 timestamps; the client uses the access expiry to refresh proactively.
|
|
56
|
-
export const nativeTokenPairSchema = z
|
|
57
|
-
.object({
|
|
58
|
-
access_token: z.string().min(1),
|
|
59
|
-
refresh_token: z.string().min(1),
|
|
60
|
-
access_token_expires_at: z.string().min(1),
|
|
61
|
-
refresh_token_expires_at: z.string().min(1),
|
|
62
|
-
})
|
|
63
|
-
.passthrough();
|
|
64
|
-
|
|
65
|
-
// What we persist in the device keychain: the two opaque tokens plus the access
|
|
66
|
-
// token's expiry (ISO-8601). This is the on-device shape, distinct from the wire
|
|
67
|
-
// shape above.
|
|
68
|
-
export const storedTokensSchema = z.object({
|
|
69
|
-
access: z.string().min(1),
|
|
70
|
-
refresh: z.string().min(1),
|
|
71
|
-
expiresAt: z.string().min(1),
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
export type NativeMembership = z.infer<typeof nativeMembershipSchema>;
|
|
75
|
-
export type NativeActiveTenant = z.infer<typeof nativeActiveTenantSchema>;
|
|
76
|
-
export type NativeUser = z.infer<typeof nativeUserSchema>;
|
|
77
|
-
export type NativeSession = z.infer<typeof nativeSessionSchema>;
|
|
78
|
-
export type NativeTokenPair = z.infer<typeof nativeTokenPairSchema>;
|
|
79
|
-
export type StoredTokens = z.infer<typeof storedTokensSchema>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// MinuteWork substrate. Thin layer — do not put product UI/logic here.
|
|
2
|
-
//
|
|
3
|
-
// Builds absolute URLs for the MinuteWork *platform native* session endpoints.
|
|
4
|
-
//
|
|
5
|
-
// These endpoints are the DIRECT platform API surface for native clients
|
|
6
|
-
// (`/api/v1/native/...`). The mobile app authenticates with a platform-issued
|
|
7
|
-
// bearer token obtained through a browser-assisted device flow, then calls the
|
|
8
|
-
// platform directly. This is intentionally NOT the tenant-app BFF cookie path
|
|
9
|
-
// (the Next.js `platform_session_bff` profile) — there is no per-app server in
|
|
10
|
-
// front of the mobile client.
|
|
11
|
-
//
|
|
12
|
-
// These routes are SHIPPED by the platform native-token slice and are called by
|
|
13
|
-
// the real device-flow client in `src/mw/client.ts`.
|
|
14
|
-
|
|
15
|
-
import { mwEnv } from "@/mw/env";
|
|
16
|
-
|
|
17
|
-
const platformBaseUrl = new URL(
|
|
18
|
-
mwEnv.platformBaseUrl.endsWith("/")
|
|
19
|
-
? mwEnv.platformBaseUrl
|
|
20
|
-
: `${mwEnv.platformBaseUrl}/`,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
function buildPlatformEndpoint(path: string): string {
|
|
24
|
-
return new URL(path.replace(/^\//, ""), platformBaseUrl).toString();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const platformNativeEndpoints = {
|
|
28
|
-
// Begin the browser-assisted device authorization flow.
|
|
29
|
-
authorize: buildPlatformEndpoint("/api/v1/native/session/authorize/"),
|
|
30
|
-
// Exchange the authorization result for an access/refresh token pair.
|
|
31
|
-
tokenExchange: buildPlatformEndpoint("/api/v1/native/session/token-exchange/"),
|
|
32
|
-
// Rotate an expired access token using the refresh token.
|
|
33
|
-
refresh: buildPlatformEndpoint("/api/v1/native/session/refresh/"),
|
|
34
|
-
// Resolve the current authenticated principal (user + active tenant).
|
|
35
|
-
me: buildPlatformEndpoint("/api/v1/native/session/me/"),
|
|
36
|
-
// Resolve / switch active tenant context for the session.
|
|
37
|
-
context: buildPlatformEndpoint("/api/v1/native/session/context/"),
|
|
38
|
-
// Revoke the current token pair.
|
|
39
|
-
logout: buildPlatformEndpoint("/api/v1/native/session/logout/"),
|
|
40
|
-
} as const;
|
|
41
|
-
|
|
42
|
-
export type PlatformNativeEndpoint = keyof typeof platformNativeEndpoints;
|