@budibase/worker 2.4.44-alpha.4 → 2.5.0

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/src/initPro.ts DELETED
@@ -1,13 +0,0 @@
1
- import { sdk as proSdk } from "@budibase/pro"
2
- import * as userSdk from "./sdk/users"
3
-
4
- export const initPro = async () => {
5
- await proSdk.init({
6
- scimUserServiceConfig: {
7
- functions: {
8
- saveUser: userSdk.save,
9
- removeUser: (id: string) => userSdk.destroy(id),
10
- },
11
- },
12
- })
13
- }
@@ -1,12 +0,0 @@
1
- import { Ctx } from "@budibase/types"
2
-
3
- export const handleScimBody = (ctx: Ctx, next: any) => {
4
- var type = ctx.req.headers["content-type"] || ""
5
- type = type.split(";")[0]
6
-
7
- if (type === "application/scim+json") {
8
- ctx.req.headers["content-type"] = "application/json"
9
- }
10
-
11
- return next()
12
- }
@@ -1,94 +0,0 @@
1
- import {
2
- ScimCreateGroupRequest,
3
- ScimGroupListResponse,
4
- ScimGroupResponse,
5
- ScimUpdateRequest,
6
- } from "@budibase/types"
7
- import TestConfiguration from "../../TestConfiguration"
8
- import { RequestSettings, ScimTestAPI } from "./shared"
9
-
10
- export class ScimGroupsAPI extends ScimTestAPI {
11
- constructor(config: TestConfiguration) {
12
- super(config)
13
- }
14
-
15
- get = async (
16
- requestSettings?: Partial<RequestSettings> & {
17
- params?: {
18
- startIndex?: number
19
- pageSize?: number
20
- filter?: string
21
- }
22
- }
23
- ) => {
24
- let url = `/api/global/scim/v2/groups?`
25
- const params = requestSettings?.params
26
- if (params?.pageSize) {
27
- url += `count=${params.pageSize}&`
28
- }
29
- if (params?.startIndex) {
30
- url += `startIndex=${params.startIndex}&`
31
- }
32
- if (params?.filter) {
33
- url += `filter=${params.filter}&`
34
- }
35
- const res = await this.call(url, "get", requestSettings)
36
- return res.body as ScimGroupListResponse
37
- }
38
-
39
- post = async (
40
- {
41
- body,
42
- }: {
43
- body: ScimCreateGroupRequest
44
- },
45
- requestSettings?: Partial<RequestSettings>
46
- ) => {
47
- const res = await this.call(
48
- `/api/global/scim/v2/groups`,
49
- "post",
50
- requestSettings,
51
- body
52
- )
53
-
54
- return res.body as ScimGroupResponse
55
- }
56
-
57
- find = async (id: string, requestSettings?: Partial<RequestSettings>) => {
58
- const res = await this.call(
59
- `/api/global/scim/v2/groups/${id}`,
60
- "get",
61
- requestSettings
62
- )
63
- return res.body as ScimGroupResponse
64
- }
65
-
66
- delete = async (id: string, requestSettings?: Partial<RequestSettings>) => {
67
- const res = await this.call(
68
- `/api/global/scim/v2/groups/${id}`,
69
- "delete",
70
- requestSettings
71
- )
72
- return res.body as ScimGroupResponse
73
- }
74
-
75
- patch = async (
76
- {
77
- id,
78
- body,
79
- }: {
80
- id: string
81
- body: ScimUpdateRequest
82
- },
83
- requestSettings?: Partial<RequestSettings>
84
- ) => {
85
- const res = await this.call(
86
- `/api/global/scim/v2/groups/${id}`,
87
- "patch",
88
- requestSettings,
89
- body
90
- )
91
-
92
- return res.body as ScimGroupResponse
93
- }
94
- }
@@ -1,43 +0,0 @@
1
- import TestConfiguration from "../../TestConfiguration"
2
- import { TestAPI } from "../base"
3
-
4
- const defaultConfig = {
5
- expect: 200,
6
- setHeaders: true,
7
- }
8
-
9
- export type RequestSettings = typeof defaultConfig
10
-
11
- export abstract class ScimTestAPI extends TestAPI {
12
- constructor(config: TestConfiguration) {
13
- super(config)
14
- }
15
-
16
- call = (
17
- url: string,
18
- method: "get" | "post" | "patch" | "delete",
19
- requestSettings?: Partial<RequestSettings>,
20
- body?: object
21
- ) => {
22
- const { expect, setHeaders } = { ...defaultConfig, ...requestSettings }
23
- let request = this.request[method](url).expect(expect)
24
-
25
- request = request.set(
26
- "content-type",
27
- "application/scim+json; charset=utf-8"
28
- )
29
-
30
- if (method !== "delete") {
31
- request = request.expect("Content-Type", /json/)
32
- }
33
-
34
- if (body) {
35
- request = request.send(body)
36
- }
37
-
38
- if (setHeaders) {
39
- request = request.set(this.config.bearerAPIHeaders())
40
- }
41
- return request
42
- }
43
- }
@@ -1,94 +0,0 @@
1
- import {
2
- ScimUserListResponse,
3
- ScimCreateUserRequest,
4
- ScimUserResponse,
5
- ScimUpdateRequest,
6
- } from "@budibase/types"
7
- import TestConfiguration from "../../TestConfiguration"
8
- import { RequestSettings, ScimTestAPI } from "./shared"
9
-
10
- export class ScimUsersAPI extends ScimTestAPI {
11
- constructor(config: TestConfiguration) {
12
- super(config)
13
- }
14
-
15
- get = async (
16
- requestSettings?: Partial<RequestSettings> & {
17
- params?: {
18
- startIndex?: number
19
- pageSize?: number
20
- filter?: string
21
- }
22
- }
23
- ) => {
24
- let url = `/api/global/scim/v2/users?`
25
- const params = requestSettings?.params
26
- if (params?.pageSize) {
27
- url += `count=${params.pageSize}&`
28
- }
29
- if (params?.startIndex) {
30
- url += `startIndex=${params.startIndex}&`
31
- }
32
- if (params?.filter) {
33
- url += `filter=${params.filter}&`
34
- }
35
- const res = await this.call(url, "get", requestSettings)
36
- return res.body as ScimUserListResponse
37
- }
38
-
39
- find = async (id: string, requestSettings?: Partial<RequestSettings>) => {
40
- const res = await this.call(
41
- `/api/global/scim/v2/users/${id}`,
42
- "get",
43
- requestSettings
44
- )
45
- return res.body as ScimUserResponse
46
- }
47
-
48
- post = async (
49
- {
50
- body,
51
- }: {
52
- body: ScimCreateUserRequest
53
- },
54
- requestSettings?: Partial<RequestSettings>
55
- ) => {
56
- const res = await this.call(
57
- `/api/global/scim/v2/users`,
58
- "post",
59
- requestSettings,
60
- body
61
- )
62
-
63
- return res.body as ScimUserResponse
64
- }
65
-
66
- patch = async (
67
- {
68
- id,
69
- body,
70
- }: {
71
- id: string
72
- body: ScimUpdateRequest
73
- },
74
- requestSettings?: Partial<RequestSettings>
75
- ) => {
76
- const res = await this.call(
77
- `/api/global/scim/v2/users/${id}`,
78
- "patch",
79
- requestSettings,
80
- body
81
- )
82
-
83
- return res.body as ScimUserResponse
84
- }
85
-
86
- delete = async (id: string, requestSettings?: Partial<RequestSettings>) => {
87
- const res = await this.call(
88
- `/api/global/scim/v2/users/${id}`,
89
- "delete",
90
- requestSettings
91
- )
92
- return res.body as ScimUserResponse
93
- }
94
- }