Skip to content

Commit 4abba72

Browse files
authored
Merge pull request #8 from karimodm/support-breaking-pb-upgrade
Support v0.23.xx breaking changes
2 parents 08657df + 1e29c8b commit 4abba72

File tree

3 files changed

+40
-29
lines changed

3 files changed

+40
-29
lines changed

Diff for: package-lock.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"js-base64": "^3.7.7",
6565
"lodash.throttle": "^4.1.1",
6666
"nomnoml": "^1.6.2",
67-
"pocketbase": "^0.21.3",
67+
"pocketbase": "^0.25.1",
6868
"prettier": "^3.3.2",
6969
"prettier-plugin-svelte": "^3.2.5",
7070
"sass": "^1.77.6",

Diff for: src/lib/diagram.ts

+33-22
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ export async function loadPocketbaseCollections(connection: Connection | undefin
5454
if (!connection) throw new Error('Missing connection parameters');
5555
const { url, email, password } = connection;
5656
const pb = new PocketBase(url);
57-
await pb.admins.authWithPassword(email, password);
58-
return pb.collections.getFullList();
57+
pb.collection('_superusers').authWithPassword(email, password);
58+
59+
return await pb.collections.getFullList();
5960
}
6061

6162
const genericMarkupDirectives = Object.entries({
@@ -75,26 +76,36 @@ export function generateMarkup(
7576
{ direction, algorithm, showSystemAttributes, markRequiredAttributes, showSelectValues }: Settings
7677
) {
7778
const entities: Record<string, Entity> = Object.fromEntries(
78-
collections.map(({ id, name, schema, $isView }) => {
79-
let attributes: Attribute[] = [
80-
...(showSystemAttributes
81-
? $isView
82-
? viewSystemAttributes
83-
: collectionSystemAttributes
84-
: [])
85-
];
86-
attributes = attributes.concat(
87-
schema.map(({ name, type, options, required }) => ({
88-
name,
89-
type,
90-
options: options as AttributeOptions,
91-
required,
92-
isRelation: type === 'relation'
93-
}))
94-
);
95-
96-
return [id, { id: sanitizeId(id), name, attributes, isView: $isView }];
97-
})
79+
collections
80+
.filter(({ system }) => !system) // Filter out system collections
81+
.map(({ id, name, fields, $isView }) => {
82+
let attributes: Attribute[] = [
83+
...(showSystemAttributes
84+
? $isView
85+
? viewSystemAttributes
86+
: collectionSystemAttributes
87+
: [])
88+
];
89+
attributes = attributes.concat(
90+
fields.map((field) => ({
91+
name: field.name,
92+
type: field.type,
93+
options: {
94+
min: field.min,
95+
max: field.max,
96+
minSelect: field.minSelect,
97+
maxSelect: field.maxSelect,
98+
cascadeDelete: field.cascadeDelete,
99+
collectionId: field.collectionId,
100+
values: field.values
101+
} as AttributeOptions,
102+
required: field.required,
103+
isRelation: field.type === 'relation'
104+
}))
105+
);
106+
107+
return [id, { id: sanitizeId(id), name, attributes, isView: $isView }];
108+
})
98109
);
99110

100111
const entityValues = Object.values(entities);

0 commit comments

Comments
 (0)