hazo_auth 5.1.7 → 5.1.8

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.
@@ -0,0 +1,33 @@
1
+ import { NextRequest, NextResponse } from "next/server";
2
+ /**
3
+ * GET /api/hazo_auth/app_user_data/schema
4
+ *
5
+ * Returns the app_user_data schema configuration for rendering the editor.
6
+ * Requires authentication.
7
+ *
8
+ * Response format (schema enabled):
9
+ * {
10
+ * success: true,
11
+ * enabled: true,
12
+ * schema: { type: "object", properties: {...} },
13
+ * section_labels: { "electronic_funds_transfer": "Bank Account Details", ... }
14
+ * }
15
+ *
16
+ * Response format (schema disabled):
17
+ * {
18
+ * success: true,
19
+ * enabled: false,
20
+ * schema: null,
21
+ * section_labels: {}
22
+ * }
23
+ */
24
+ export declare function GET(request: NextRequest): Promise<NextResponse<{
25
+ error: string;
26
+ }> | NextResponse<{
27
+ success: boolean;
28
+ enabled: boolean;
29
+ schema: import("../../lib/app_user_data_config.server").AppUserDataSchema | null;
30
+ section_labels: Record<string, string>;
31
+ field_labels: Record<string, Record<string, string>>;
32
+ }>>;
33
+ //# sourceMappingURL=app_user_data_schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app_user_data_schema.d.ts","sourceRoot":"","sources":["../../../src/server/routes/app_user_data_schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAUxD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,GAAG,CAAC,OAAO,EAAE,WAAW;;;;;;;;IAkD7C"}
@@ -0,0 +1,72 @@
1
+ // file_description: API route handler to get app_user_data schema configuration
2
+ // Returns the JSON schema and section labels for the app_user_data editor
3
+ // section: imports
4
+ import { NextResponse } from "next/server";
5
+ import { hazo_get_auth } from "../../lib/auth/hazo_get_auth.server.js";
6
+ import { get_app_user_data_config, get_section_label, get_field_label, } from "../../lib/app_user_data_config.server.js";
7
+ // section: api_handler
8
+ /**
9
+ * GET /api/hazo_auth/app_user_data/schema
10
+ *
11
+ * Returns the app_user_data schema configuration for rendering the editor.
12
+ * Requires authentication.
13
+ *
14
+ * Response format (schema enabled):
15
+ * {
16
+ * success: true,
17
+ * enabled: true,
18
+ * schema: { type: "object", properties: {...} },
19
+ * section_labels: { "electronic_funds_transfer": "Bank Account Details", ... }
20
+ * }
21
+ *
22
+ * Response format (schema disabled):
23
+ * {
24
+ * success: true,
25
+ * enabled: false,
26
+ * schema: null,
27
+ * section_labels: {}
28
+ * }
29
+ */
30
+ export async function GET(request) {
31
+ try {
32
+ const auth_result = await hazo_get_auth(request);
33
+ if (!auth_result.authenticated) {
34
+ return NextResponse.json({ error: "Authentication required" }, { status: 401 });
35
+ }
36
+ const config = get_app_user_data_config();
37
+ // Convert Map to plain object for JSON response
38
+ const section_labels = {};
39
+ config.section_labels.forEach((value, key) => {
40
+ section_labels[key] = value;
41
+ });
42
+ // If schema is enabled, also compute labels for each field
43
+ const field_labels = {};
44
+ if (config.enable_schema && config.schema) {
45
+ for (const [section_key, section_prop] of Object.entries(config.schema.properties)) {
46
+ if (section_prop.type === "object" && section_prop.properties) {
47
+ field_labels[section_key] = {};
48
+ for (const field_key of Object.keys(section_prop.properties)) {
49
+ field_labels[section_key][field_key] = get_field_label(field_key, section_key);
50
+ }
51
+ }
52
+ }
53
+ // Add section labels for keys not explicitly defined
54
+ for (const section_key of Object.keys(config.schema.properties)) {
55
+ if (!section_labels[section_key]) {
56
+ section_labels[section_key] = get_section_label(section_key);
57
+ }
58
+ }
59
+ }
60
+ return NextResponse.json({
61
+ success: true,
62
+ enabled: config.enable_schema && config.schema !== null,
63
+ schema: config.schema,
64
+ section_labels,
65
+ field_labels,
66
+ });
67
+ }
68
+ catch (error) {
69
+ const error_message = error instanceof Error ? error.message : "Unknown error";
70
+ return NextResponse.json({ error: error_message }, { status: 500 });
71
+ }
72
+ }
@@ -21,6 +21,7 @@ export { GET as userManagementPermissionsGET, POST as userManagementPermissionsP
21
21
  export { GET as userManagementRolesGET, POST as userManagementRolesPOST, PUT as userManagementRolesPUT } from "./user_management_roles.js";
22
22
  export { GET as userManagementUsersRolesGET, POST as userManagementUsersRolesPOST, PUT as userManagementUsersRolesPUT } from "./user_management_users_roles.js";
23
23
  export { GET as appUserDataGET, PATCH as appUserDataPATCH, PUT as appUserDataPUT, DELETE as appUserDataDELETE } from "./app_user_data.js";
24
+ export { GET as appUserDataSchemaGET } from "./app_user_data_schema.js";
24
25
  export { GET as invitationsGET, POST as invitationsPOST, PATCH as invitationsPATCH, DELETE as invitationsDELETE } from "./invitations.js";
25
26
  export { POST as createFirmPOST } from "./create_firm.js";
26
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/routes/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,GAAG,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,IAAI,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,IAAI,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,IAAI,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,GAAG,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGzE,OAAO,EAAE,GAAG,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,IAAI,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAG1E,OAAO,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,kBAAkB,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AAC;AACpD,OAAO,EAAE,IAAI,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGpE,OAAO,EAAE,GAAG,IAAI,sBAAsB,EAAE,KAAK,IAAI,wBAAwB,EAAE,IAAI,IAAI,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC/I,OAAO,EAAE,GAAG,IAAI,4BAA4B,EAAE,IAAI,IAAI,6BAA6B,EAAE,GAAG,IAAI,4BAA4B,EAAE,MAAM,IAAI,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AAC9M,OAAO,EAAE,GAAG,IAAI,sBAAsB,EAAE,IAAI,IAAI,uBAAuB,EAAE,GAAG,IAAI,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC3I,OAAO,EAAE,GAAG,IAAI,2BAA2B,EAAE,IAAI,IAAI,4BAA4B,EAAE,GAAG,IAAI,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAGhK,OAAO,EAAE,GAAG,IAAI,cAAc,EAAE,KAAK,IAAI,gBAAgB,EAAE,GAAG,IAAI,cAAc,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1I,OAAO,EAAE,GAAG,IAAI,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGxE,OAAO,EAAE,GAAG,IAAI,cAAc,EAAE,IAAI,IAAI,eAAe,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1I,OAAO,EAAE,IAAI,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -30,6 +30,7 @@ export { GET as userManagementRolesGET, POST as userManagementRolesPOST, PUT as
30
30
  export { GET as userManagementUsersRolesGET, POST as userManagementUsersRolesPOST, PUT as userManagementUsersRolesPUT } from "./user_management_users_roles.js";
31
31
  // App user data routes (custom application-specific user data)
32
32
  export { GET as appUserDataGET, PATCH as appUserDataPATCH, PUT as appUserDataPUT, DELETE as appUserDataDELETE } from "./app_user_data.js";
33
+ export { GET as appUserDataSchemaGET } from "./app_user_data_schema.js";
33
34
  // Invitation routes (for inviting users to scopes)
34
35
  export { GET as invitationsGET, POST as invitationsPOST, PATCH as invitationsPATCH, DELETE as invitationsDELETE } from "./invitations.js";
35
36
  // Create firm routes (for new users creating their firm)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_auth",
3
- "version": "5.1.7",
3
+ "version": "5.1.8",
4
4
  "description": "Zero-config authentication UI components for Next.js with RBAC, OAuth, scope-based multi-tenancy, and invitations",
5
5
  "keywords": [
6
6
  "authentication",