@tscircuit/fake-snippets 0.0.117 → 0.0.118
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/bun-tests/fake-snippets-api/routes/orgs/get_member.test.ts +110 -0
- package/bun-tests/fake-snippets-api/routes/orgs/list_members.test.ts +4 -3
- package/bun.lock +2 -2
- package/dist/bundle.js +462 -370
- package/dist/index.js +5 -4
- package/dist/schema.d.ts +12 -1
- package/dist/schema.js +7 -5
- package/fake-snippets-api/lib/db/schema.ts +7 -6
- package/fake-snippets-api/routes/api/orgs/get_member.ts +67 -0
- package/fake-snippets-api/routes/api/orgs/list_members.ts +40 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -351,6 +351,10 @@ var orgAccountSchema = z.object({
|
|
|
351
351
|
is_owner: z.boolean().default(false),
|
|
352
352
|
created_at: z.string().datetime()
|
|
353
353
|
});
|
|
354
|
+
var userPermissionsSchema = z.object({
|
|
355
|
+
can_manage_org: z.boolean().optional(),
|
|
356
|
+
can_manage_package: z.boolean().optional()
|
|
357
|
+
});
|
|
354
358
|
var publicOrgSchema = z.object({
|
|
355
359
|
org_id: z.string(),
|
|
356
360
|
//.uuid(),
|
|
@@ -363,10 +367,7 @@ var publicOrgSchema = z.object({
|
|
|
363
367
|
package_count: z.number(),
|
|
364
368
|
github_handle: z.string().optional(),
|
|
365
369
|
created_at: z.string(),
|
|
366
|
-
user_permissions:
|
|
367
|
-
can_manage_org: z.boolean().optional(),
|
|
368
|
-
can_manage_package: z.boolean().optional()
|
|
369
|
-
}).optional()
|
|
370
|
+
user_permissions: userPermissionsSchema.optional()
|
|
370
371
|
});
|
|
371
372
|
var databaseSchema = z.object({
|
|
372
373
|
idCounter: z.number().default(0),
|
package/dist/schema.d.ts
CHANGED
|
@@ -1165,6 +1165,17 @@ declare const orgAccountSchema: z.ZodObject<{
|
|
|
1165
1165
|
is_owner?: boolean | undefined;
|
|
1166
1166
|
}>;
|
|
1167
1167
|
type OrgAccount = z.infer<typeof orgAccountSchema>;
|
|
1168
|
+
declare const userPermissionsSchema: z.ZodObject<{
|
|
1169
|
+
can_manage_org: z.ZodOptional<z.ZodBoolean>;
|
|
1170
|
+
can_manage_package: z.ZodOptional<z.ZodBoolean>;
|
|
1171
|
+
}, "strip", z.ZodTypeAny, {
|
|
1172
|
+
can_manage_org?: boolean | undefined;
|
|
1173
|
+
can_manage_package?: boolean | undefined;
|
|
1174
|
+
}, {
|
|
1175
|
+
can_manage_org?: boolean | undefined;
|
|
1176
|
+
can_manage_package?: boolean | undefined;
|
|
1177
|
+
}>;
|
|
1178
|
+
type UserPermissions = z.infer<typeof userPermissionsSchema>;
|
|
1168
1179
|
declare const publicOrgSchema: z.ZodObject<{
|
|
1169
1180
|
org_id: z.ZodString;
|
|
1170
1181
|
owner_account_id: z.ZodString;
|
|
@@ -2910,4 +2921,4 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
2910
2921
|
}>;
|
|
2911
2922
|
type DatabaseSchema = z.infer<typeof databaseSchema>;
|
|
2912
2923
|
|
|
2913
|
-
export { type Account, type AccountPackage, type AccountSnippet, type AiReview, type DatabaseSchema, type Datasheet, type GithubInstallation, type JlcpcbOrderState, type JlcpcbOrderStepRun, type LoginPage, type Order, type OrderFile, type OrderQuote, type OrgAccount, type Organization, type Package, type PackageBuild, type PackageFile, type PackageRelease, type PublicOrgSchema, type QuotedComponent, type Session, type ShippingOption, type Snippet, accountPackageSchema, accountSchema, accountSnippetSchema, aiReviewSchema, databaseSchema, datasheetPinInformationSchema, datasheetSchema, errorResponseSchema, errorSchema, githubInstallationSchema, jlcpcbOrderStateSchema, jlcpcbOrderStepRunSchema, loginPageSchema, orderFileSchema, orderQuoteSchema, orderSchema, orgAccountSchema, orgSchema, packageBuildSchema, packageFileSchema, packageReleaseSchema, packageSchema, publicOrgSchema, quotedComponentSchema, sessionSchema, shippingInfoSchema, snippetSchema };
|
|
2924
|
+
export { type Account, type AccountPackage, type AccountSnippet, type AiReview, type DatabaseSchema, type Datasheet, type GithubInstallation, type JlcpcbOrderState, type JlcpcbOrderStepRun, type LoginPage, type Order, type OrderFile, type OrderQuote, type OrgAccount, type Organization, type Package, type PackageBuild, type PackageFile, type PackageRelease, type PublicOrgSchema, type QuotedComponent, type Session, type ShippingOption, type Snippet, type UserPermissions, accountPackageSchema, accountSchema, accountSnippetSchema, aiReviewSchema, databaseSchema, datasheetPinInformationSchema, datasheetSchema, errorResponseSchema, errorSchema, githubInstallationSchema, jlcpcbOrderStateSchema, jlcpcbOrderStepRunSchema, loginPageSchema, orderFileSchema, orderQuoteSchema, orderSchema, orgAccountSchema, orgSchema, packageBuildSchema, packageFileSchema, packageReleaseSchema, packageSchema, publicOrgSchema, quotedComponentSchema, sessionSchema, shippingInfoSchema, snippetSchema, userPermissionsSchema };
|
package/dist/schema.js
CHANGED
|
@@ -346,6 +346,10 @@ var orgAccountSchema = z.object({
|
|
|
346
346
|
is_owner: z.boolean().default(false),
|
|
347
347
|
created_at: z.string().datetime()
|
|
348
348
|
});
|
|
349
|
+
var userPermissionsSchema = z.object({
|
|
350
|
+
can_manage_org: z.boolean().optional(),
|
|
351
|
+
can_manage_package: z.boolean().optional()
|
|
352
|
+
});
|
|
349
353
|
var publicOrgSchema = z.object({
|
|
350
354
|
org_id: z.string(),
|
|
351
355
|
//.uuid(),
|
|
@@ -358,10 +362,7 @@ var publicOrgSchema = z.object({
|
|
|
358
362
|
package_count: z.number(),
|
|
359
363
|
github_handle: z.string().optional(),
|
|
360
364
|
created_at: z.string(),
|
|
361
|
-
user_permissions:
|
|
362
|
-
can_manage_org: z.boolean().optional(),
|
|
363
|
-
can_manage_package: z.boolean().optional()
|
|
364
|
-
}).optional()
|
|
365
|
+
user_permissions: userPermissionsSchema.optional()
|
|
365
366
|
});
|
|
366
367
|
var databaseSchema = z.object({
|
|
367
368
|
idCounter: z.number().default(0),
|
|
@@ -413,5 +414,6 @@ export {
|
|
|
413
414
|
quotedComponentSchema,
|
|
414
415
|
sessionSchema,
|
|
415
416
|
shippingInfoSchema,
|
|
416
|
-
snippetSchema
|
|
417
|
+
snippetSchema,
|
|
418
|
+
userPermissionsSchema
|
|
417
419
|
};
|
|
@@ -419,6 +419,12 @@ export const orgAccountSchema = z.object({
|
|
|
419
419
|
})
|
|
420
420
|
export type OrgAccount = z.infer<typeof orgAccountSchema>
|
|
421
421
|
|
|
422
|
+
export const userPermissionsSchema = z.object({
|
|
423
|
+
can_manage_org: z.boolean().optional(),
|
|
424
|
+
can_manage_package: z.boolean().optional(),
|
|
425
|
+
})
|
|
426
|
+
export type UserPermissions = z.infer<typeof userPermissionsSchema>
|
|
427
|
+
|
|
422
428
|
export const publicOrgSchema = z.object({
|
|
423
429
|
org_id: z.string(), //.uuid(),
|
|
424
430
|
owner_account_id: z.string(), //.uuid(),
|
|
@@ -429,12 +435,7 @@ export const publicOrgSchema = z.object({
|
|
|
429
435
|
package_count: z.number(),
|
|
430
436
|
github_handle: z.string().optional(),
|
|
431
437
|
created_at: z.string(),
|
|
432
|
-
user_permissions:
|
|
433
|
-
.object({
|
|
434
|
-
can_manage_org: z.boolean().optional(),
|
|
435
|
-
can_manage_package: z.boolean().optional(),
|
|
436
|
-
})
|
|
437
|
-
.optional(),
|
|
438
|
+
user_permissions: userPermissionsSchema.optional(),
|
|
438
439
|
})
|
|
439
440
|
export type PublicOrgSchema = z.infer<typeof publicOrgSchema>
|
|
440
441
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { withRouteSpec } from "fake-snippets-api/lib/middleware/with-winter-spec"
|
|
2
|
+
import { z } from "zod"
|
|
3
|
+
import {
|
|
4
|
+
orgAccountSchema,
|
|
5
|
+
userPermissionsSchema,
|
|
6
|
+
} from "fake-snippets-api/lib/db/schema"
|
|
7
|
+
|
|
8
|
+
export default withRouteSpec({
|
|
9
|
+
methods: ["GET"],
|
|
10
|
+
commonParams: z.object({
|
|
11
|
+
org_id: z.string().optional(),
|
|
12
|
+
org_name: z.string().optional(),
|
|
13
|
+
account_id: z.string(),
|
|
14
|
+
}),
|
|
15
|
+
auth: "optional_session",
|
|
16
|
+
jsonResponse: z.object({
|
|
17
|
+
org_member: orgAccountSchema.merge(
|
|
18
|
+
z.object({ org_member_permissions: userPermissionsSchema.nullable() }),
|
|
19
|
+
),
|
|
20
|
+
}),
|
|
21
|
+
})(async (req, ctx) => {
|
|
22
|
+
const { org_id, org_name, account_id } = req.commonParams
|
|
23
|
+
|
|
24
|
+
const org = ctx.db.getOrg(
|
|
25
|
+
{
|
|
26
|
+
org_id,
|
|
27
|
+
org_name,
|
|
28
|
+
},
|
|
29
|
+
ctx.auth,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
if (!org) {
|
|
33
|
+
return ctx.error(404, {
|
|
34
|
+
error_code: "org_not_found",
|
|
35
|
+
message: "Organization not found",
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const memberOrgAccount = ctx.db.getOrganizationAccount({
|
|
40
|
+
org_id: org.org_id,
|
|
41
|
+
account_id: account_id,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const memberOrg = ctx.db.getOrg(
|
|
45
|
+
{
|
|
46
|
+
org_id,
|
|
47
|
+
org_name,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
account_id: account_id!,
|
|
51
|
+
},
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
if (!memberOrgAccount) {
|
|
55
|
+
return ctx.error(404, {
|
|
56
|
+
error_code: "member_not_found",
|
|
57
|
+
message: "Member not found in organization",
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return ctx.json({
|
|
62
|
+
org_member: {
|
|
63
|
+
...memberOrgAccount,
|
|
64
|
+
org_member_permissions: memberOrg,
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
})
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { withRouteSpec } from "fake-snippets-api/lib/middleware/with-winter-spec"
|
|
2
2
|
import { z } from "zod"
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
accountSchema,
|
|
5
|
+
userPermissionsSchema,
|
|
6
|
+
} from "fake-snippets-api/lib/db/schema"
|
|
4
7
|
|
|
5
8
|
export default withRouteSpec({
|
|
6
9
|
methods: ["GET", "POST"],
|
|
@@ -15,7 +18,12 @@ export default withRouteSpec({
|
|
|
15
18
|
),
|
|
16
19
|
auth: "optional_session",
|
|
17
20
|
jsonResponse: z.object({
|
|
18
|
-
|
|
21
|
+
org_members: z.array(
|
|
22
|
+
accountSchema.omit({ shippingInfo: true }).extend({
|
|
23
|
+
joined_at: z.string(),
|
|
24
|
+
org_member_permissions: userPermissionsSchema,
|
|
25
|
+
}),
|
|
26
|
+
),
|
|
19
27
|
}),
|
|
20
28
|
})(async (req, ctx) => {
|
|
21
29
|
const params = req.commonParams as { org_id?: string; name?: string }
|
|
@@ -40,8 +48,19 @@ export default withRouteSpec({
|
|
|
40
48
|
if (m.org_id !== org.org_id) return undefined
|
|
41
49
|
const account = ctx.db.getAccount(m.account_id)
|
|
42
50
|
if (!account) return undefined
|
|
51
|
+
const memberOrg = ctx.db.getOrg(
|
|
52
|
+
{
|
|
53
|
+
org_id: org.org_id,
|
|
54
|
+
org_name: org.org_name,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
account_id: account.account_id,
|
|
58
|
+
},
|
|
59
|
+
)
|
|
60
|
+
|
|
43
61
|
return {
|
|
44
62
|
...account,
|
|
63
|
+
user_permissions: memberOrg,
|
|
45
64
|
joined_at: m.created_at,
|
|
46
65
|
}
|
|
47
66
|
})
|
|
@@ -56,15 +75,32 @@ export default withRouteSpec({
|
|
|
56
75
|
(acc) => acc.account_id === org.owner_account_id,
|
|
57
76
|
)
|
|
58
77
|
if (owner) {
|
|
78
|
+
const memberOrg = ctx.db.getOrg(
|
|
79
|
+
{
|
|
80
|
+
org_id: org.org_id,
|
|
81
|
+
org_name: org.org_name,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
account_id: owner.account_id,
|
|
85
|
+
},
|
|
86
|
+
)
|
|
59
87
|
fullMembers = [
|
|
60
88
|
...members,
|
|
61
89
|
{
|
|
62
90
|
...owner,
|
|
91
|
+
user_permissions: memberOrg,
|
|
63
92
|
joined_at: org.created_at,
|
|
64
93
|
},
|
|
65
94
|
]
|
|
66
95
|
}
|
|
67
96
|
}
|
|
68
|
-
|
|
69
|
-
|
|
97
|
+
return ctx.json({
|
|
98
|
+
org_members: fullMembers.map((m) => ({
|
|
99
|
+
...m,
|
|
100
|
+
org_member_permissions: m.user_permissions ?? {
|
|
101
|
+
can_manage_org: false,
|
|
102
|
+
can_manage_package: false,
|
|
103
|
+
},
|
|
104
|
+
})),
|
|
105
|
+
})
|
|
70
106
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/fake-snippets",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.118",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@tscircuit/3d-viewer": "^0.0.407",
|
|
82
82
|
"@tscircuit/assembly-viewer": "^0.0.5",
|
|
83
83
|
"@tscircuit/create-snippet-url": "^0.0.8",
|
|
84
|
-
"@tscircuit/eval": "^0.0.
|
|
84
|
+
"@tscircuit/eval": "^0.0.410",
|
|
85
85
|
"@tscircuit/layout": "^0.0.29",
|
|
86
86
|
"@tscircuit/mm": "^0.0.8",
|
|
87
87
|
"@tscircuit/pcb-viewer": "^1.11.218",
|