@nymphjs/tilmeld-client 1.0.0-beta.14 → 1.0.0-beta.141

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/package.json CHANGED
@@ -1,52 +1,56 @@
1
1
  {
2
2
  "name": "@nymphjs/tilmeld-client",
3
- "version": "1.0.0-beta.14",
4
- "description": "NymphJS - Tilmeld Client",
5
- "browser": "dist/index.js",
6
- "main": "lib/index.js",
7
- "types": "lib/index.d.ts",
3
+ "version": "1.0.0-beta.141",
4
+ "description": "Nymph.js - Tilmeld Client",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
8
  "keywords": [
9
9
  "nymph",
10
- "ORM",
11
- "object relational mapper"
10
+ "nymph.js",
11
+ "application data framework",
12
+ "application data and access framework",
13
+ "tilmeld"
12
14
  ],
13
15
  "scripts": {
14
- "clean": "npm run clean:ts && npm run clean:js",
15
- "clean:ts": "test -d lib && rm -r lib || true",
16
- "clean:js": "test -d dist && rm -r dist || true",
17
- "build": "npm run build:ts && npm run build:js",
18
- "build:ts": "tsc",
19
- "build:js": "webpack",
20
- "watch:ts": "tsc --watch",
21
- "watch:js": "webpack --watch",
22
- "prepare": "npm run clean && npm run build",
23
- "test": "jest --detectOpenHandles",
24
- "test:watch": "jest --watch"
16
+ "clean": "test -d dist && rm -r dist || true",
17
+ "build": "tsc",
18
+ "watch": "tsc --watch",
19
+ "prepublish": "npm run clean && npm run build",
20
+ "typecheck": "npx tsc --noEmit",
21
+ "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
22
+ "test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests --watch"
25
23
  },
26
24
  "publishConfig": {
27
25
  "access": "public"
28
26
  },
27
+ "homepage": "https://nymph.io",
29
28
  "repository": {
30
29
  "type": "git",
31
- "url": "git+https://github.com/sciactive/nymphjs.git"
30
+ "url": "https://forge.sciactive.com/sciactive/nymphjs.git",
31
+ "directory": "packages/tilmeld-client"
32
32
  },
33
- "author": "Hunter Perrin <hperrin@gmail.com>",
33
+ "author": "Hunter Perrin <hperrin@port87.com>",
34
34
  "bugs": {
35
- "url": "https://github.com/sciactive/nymphjs/issues"
35
+ "url": "https://forge.sciactive.com/sciactive/nymphjs/issues"
36
36
  },
37
37
  "license": "Apache-2.0",
38
- "devDependencies": {
39
- "@tsconfig/recommended": "^1.0.2",
40
- "@types/jest": "^29.4.0",
41
- "jest": "^29.4.3",
42
- "ts-jest": "^29.0.5",
43
- "ts-loader": "^9.4.2",
44
- "typescript": "^4.9.5",
45
- "webpack": "^5.75.0",
46
- "webpack-cli": "^5.0.1"
47
- },
48
38
  "dependencies": {
49
- "@nymphjs/client": "^1.0.0-beta.14"
39
+ "@nymphjs/client": "^1.0.0-beta.141"
40
+ },
41
+ "devDependencies": {
42
+ "@nymphjs/driver-sqlite3": "^1.0.0-beta.141",
43
+ "@nymphjs/nymph": "^1.0.0-beta.141",
44
+ "@nymphjs/server": "^1.0.0-beta.141",
45
+ "@nymphjs/tilmeld": "^1.0.0-beta.141",
46
+ "@swc/core": "^1.16.1",
47
+ "@swc/jest": "^0.2.39",
48
+ "@tsconfig/recommended": "^1.0.13",
49
+ "@types/jest": "^30.0.0",
50
+ "cross-env": "^10.1.0",
51
+ "jest": "^30.4.2",
52
+ "ts-node": "^10.9.2",
53
+ "typescript": "^7.0.2"
50
54
  },
51
- "gitHead": "5999838901bd6fc2fbbf44ca0b0ca990094396c3"
55
+ "gitHead": "976caad27c041b5b8dc5a897f6b2250cdbf9f20b"
52
56
  }
package/src/Group.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { Entity, Options, Selector } from '@nymphjs/client';
2
2
 
3
- import type User from './User';
4
- import type { CurrentUserData } from './User';
3
+ import type { User, CurrentUserData } from './User.js';
5
4
 
6
- export type GroupData = {
5
+ export interface GroupData {
7
6
  /**
8
7
  * The group's groupname.
9
8
  */
@@ -19,7 +18,7 @@ export type GroupData = {
19
18
  /**
20
19
  * The group's parent.
21
20
  */
22
- parent?: Group & GroupData;
21
+ parent?: Group;
23
22
 
24
23
  /**
25
24
  * Whether the group can be used.
@@ -37,9 +36,9 @@ export type GroupData = {
37
36
  * Whether this group is a default secondary group for unverified users.
38
37
  */
39
38
  unverifiedSecondary?: boolean;
40
- };
39
+ }
41
40
 
42
- export type CurrentGroupData = GroupData & {
41
+ export interface CurrentGroupData extends GroupData {
43
42
  /**
44
43
  * The abilities granted to the group.
45
44
  */
@@ -56,70 +55,111 @@ export type CurrentGroupData = GroupData & {
56
55
  * If generatePrimary is on, this will be the user who generated this group.
57
56
  */
58
57
  user?: (User & CurrentUserData) | null;
59
- };
58
+ }
59
+
60
+ export interface AdminGroupData extends CurrentGroupData {}
60
61
 
61
- export type AdminGroupData = CurrentGroupData;
62
+ export interface Group extends GroupData {}
62
63
 
63
- export default class Group extends Entity<GroupData> {
64
+ export class Group extends Entity<GroupData> {
64
65
  // The name of the server class
65
66
  public static class = 'Group';
66
67
 
67
- constructor(guid?: string) {
68
- super(guid);
69
-
70
- if (guid == null) {
71
- this.$data.enabled = true;
72
- (this.$data as CurrentGroupData).abilities = [];
68
+ static async factoryGroupname(groupname?: string): Promise<Group> {
69
+ const entity = new this();
70
+ if (groupname != null) {
71
+ const entity = await this.nymph.getEntity(
72
+ {
73
+ class: this,
74
+ },
75
+ {
76
+ type: '&',
77
+ ilike: ['groupname', groupname.replace(/([\\%_])/g, (s) => `\\${s}`)],
78
+ },
79
+ );
80
+ if (entity != null) {
81
+ return entity;
82
+ }
73
83
  }
84
+ return entity;
74
85
  }
75
86
 
76
- static async factory(guid?: string): Promise<Group & GroupData> {
77
- return (await super.factory(guid)) as Group & GroupData;
78
- }
87
+ constructor() {
88
+ super();
79
89
 
80
- static factorySync(guid?: string): Group & GroupData {
81
- return super.factorySync(guid) as Group & GroupData;
90
+ this.enabled = true;
91
+ (this as CurrentGroupData).abilities = [];
82
92
  }
83
93
 
84
94
  public async $checkGroupname(): Promise<{
85
95
  result: boolean;
86
96
  message: string;
87
97
  }> {
88
- return await this.$serverCall('$checkGroupname', [], true);
98
+ return await this.$serverCall('$checkGroupname', [], {
99
+ pushState: true,
100
+ });
89
101
  }
90
102
 
91
103
  public async $checkEmail(): Promise<{ result: boolean; message: string }> {
92
- return await this.$serverCall('$checkEmail', [], true);
104
+ return await this.$serverCall('$checkEmail', [], {
105
+ pushState: true,
106
+ });
93
107
  }
94
108
 
95
109
  public async $getAvatar(): Promise<string> {
96
- return await this.$serverCall('$getAvatar', [], true);
110
+ return await this.$serverCall('$getAvatar', [], {
111
+ pushState: true,
112
+ });
97
113
  }
98
114
 
99
- public async $getChildren(): Promise<(Group & GroupData)[]> {
100
- return await this.$serverCall('$getChildren', [], true);
115
+ public async $getChildren(
116
+ limit?: number,
117
+ offset?: number,
118
+ reverse?: boolean,
119
+ sort?: string,
120
+ ): Promise<Group[]> {
121
+ return await this.$serverCall('$getChildren', [
122
+ limit,
123
+ offset,
124
+ reverse,
125
+ sort,
126
+ ]);
101
127
  }
102
128
 
103
- public async $getDescendants(
104
- andSelf = false
105
- ): Promise<(Group & GroupData)[]> {
106
- return await this.$serverCall('$getDescendants', [andSelf], true);
129
+ public async $getDescendants(andSelf = false): Promise<Group[]> {
130
+ return await this.$serverCall('$getDescendants', [andSelf]);
107
131
  }
108
132
 
109
133
  public async $getLevel(): Promise<number> {
110
- return await this.$serverCall('$getLevel', [], true);
134
+ return await this.$serverCall('$getLevel', []);
135
+ }
136
+
137
+ public async $isDescendant(givenGroup: Group | string): Promise<boolean> {
138
+ return await this.$serverCall('$isDescendant', [givenGroup]);
111
139
  }
112
140
 
113
- public async $isDescendant(
114
- givenGroup: (Group & GroupData) | string
115
- ): Promise<boolean> {
116
- return await this.$serverCall('$isDescendant', [givenGroup], true);
141
+ public async $getUsers(
142
+ descendants = false,
143
+ limit?: number,
144
+ offset?: number,
145
+ reverse?: boolean,
146
+ sort?: string,
147
+ enabled?: boolean,
148
+ ): Promise<User[]> {
149
+ return await this.$serverCall('$getUsers', [
150
+ descendants,
151
+ limit,
152
+ offset,
153
+ reverse,
154
+ sort,
155
+ enabled,
156
+ ]);
117
157
  }
118
158
 
119
159
  public static async getPrimaryGroups(
120
160
  options?: Options,
121
- selectors?: Selector[]
122
- ): Promise<(Group & GroupData)[]> {
161
+ selectors?: Selector[],
162
+ ): Promise<Group[]> {
123
163
  return await this.serverCallStatic('getPrimaryGroups', [
124
164
  { options, class: this.class },
125
165
  selectors,
@@ -128,8 +168,8 @@ export default class Group extends Entity<GroupData> {
128
168
 
129
169
  public static async getSecondaryGroups(
130
170
  options?: Options,
131
- selectors?: Selector[]
132
- ): Promise<(Group & GroupData)[]> {
171
+ selectors?: Selector[],
172
+ ): Promise<Group[]> {
133
173
  return await this.serverCallStatic('getSecondaryGroups', [
134
174
  { options, class: this.class },
135
175
  selectors,
@@ -0,0 +1,13 @@
1
+ import { Group } from './Group.js';
2
+ import { User } from './User.js';
3
+
4
+ export interface AccessControlData {
5
+ user?: User;
6
+ group?: Group;
7
+ acUser?: number;
8
+ acGroup?: number;
9
+ acOther?: number;
10
+ acFull?: string[];
11
+ acWrite?: string[];
12
+ acRead?: string[];
13
+ }