retoolrpc 0.1.7 → 0.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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var dedent = require('ts-dedent');
4
- var rpc$1 = require('./rpc-9b3e6aef.js');
4
+ var rpc$1 = require('./rpc-5b819769.js');
5
5
  require('uuid');
6
6
  require('node-fetch');
7
7
  require('abort-controller');
package/dist/cjs/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var rpc = require('./rpc-9b3e6aef.js');
5
+ var rpc = require('./rpc-5b819769.js');
6
6
  require('uuid');
7
7
  require('ts-dedent');
8
8
  require('node-fetch');
@@ -22,7 +22,7 @@ function sequelizeMixin(Base) {
22
22
  function capitalize(str) {
23
23
  return str.charAt(0).toUpperCase() + str.slice(1);
24
24
  }
25
- function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttributes, }) {
25
+ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttributes, permissions, }) {
26
26
  const modelName = capitalize(model.name);
27
27
  // this will give us not just the name of the attribute, but also their type
28
28
  const modelAttributes = model.getAttributes();
@@ -41,6 +41,7 @@ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttr
41
41
  rpc.register({
42
42
  name: `${modelName} > create`,
43
43
  arguments: writeAttributeArgs,
44
+ permissions,
44
45
  implementation: async (args) => {
45
46
  if (typeof args !== 'object' || Array.isArray(args)) {
46
47
  throw 'attributes must be an object';
@@ -59,6 +60,7 @@ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttr
59
60
  primaryKey: { type: 'string', required: true },
60
61
  ...writeAttributeArgs,
61
62
  },
63
+ permissions,
62
64
  implementation: async ({ primaryKey, ...attributes }) => {
63
65
  return model.update(attributes, {
64
66
  where: {
@@ -73,6 +75,7 @@ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttr
73
75
  findAttributes: { type: 'dict', required: true },
74
76
  ...writeAttributeArgs,
75
77
  },
78
+ permissions,
76
79
  implementation: async ({ findAttributes, ...writeAttributes }) => {
77
80
  // Note: this is susceptible to race condition if there is no unique index
78
81
  // on the find attributes. It's the user's responsibility to avoid
@@ -96,6 +99,7 @@ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttr
96
99
  offset: { type: 'number' },
97
100
  limit: { type: 'number' },
98
101
  },
102
+ permissions,
99
103
  implementation: async ({ offset, limit }) => {
100
104
  return model.findAll({
101
105
  attributes: readAttributes,
@@ -110,6 +114,7 @@ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttr
110
114
  arguments: {
111
115
  primaryKey: { type: 'string', required: true },
112
116
  },
117
+ permissions,
113
118
  implementation: async ({ primaryKey }) => {
114
119
  return model.findByPk(primaryKey, {
115
120
  attributes: readAttributes,
@@ -120,6 +125,7 @@ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttr
120
125
  rpc.register({
121
126
  name: `${modelName} > findBy`,
122
127
  arguments: findByAttributeArgs,
128
+ permissions,
123
129
  implementation: async (attributesValues) => {
124
130
  return model.findAll({
125
131
  where: attributesValues,
@@ -287,7 +287,7 @@ class Logger {
287
287
  }
288
288
  }
289
289
 
290
- const RetoolRPCVersion = '0.1.7';
290
+ const RetoolRPCVersion = '0.1.8';
291
291
 
292
292
  // AbortController was added in node v14.17.0 globally, but we need to polyfill it for older versions
293
293
  const AbortController = globalThis.AbortController || AbortControllerFallback__default["default"];
package/dist/example.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import dedent from 'ts-dedent';
2
- import { R as RetoolRPC } from './rpc-f78d3d6d.mjs';
2
+ import { R as RetoolRPC } from './rpc-2039046c.mjs';
3
3
  import 'uuid';
4
4
  import 'node-fetch';
5
5
  import 'abort-controller';
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { R as RetoolRPC } from './rpc-f78d3d6d.mjs';
1
+ export { R as RetoolRPC } from './rpc-2039046c.mjs';
2
2
  import 'uuid';
3
3
  import 'ts-dedent';
4
4
  import 'node-fetch';
@@ -18,7 +18,7 @@ function sequelizeMixin(Base) {
18
18
  function capitalize(str) {
19
19
  return str.charAt(0).toUpperCase() + str.slice(1);
20
20
  }
21
- function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttributes, }) {
21
+ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttributes, permissions, }) {
22
22
  const modelName = capitalize(model.name);
23
23
  // this will give us not just the name of the attribute, but also their type
24
24
  const modelAttributes = model.getAttributes();
@@ -37,6 +37,7 @@ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttr
37
37
  rpc.register({
38
38
  name: `${modelName} > create`,
39
39
  arguments: writeAttributeArgs,
40
+ permissions,
40
41
  implementation: async (args) => {
41
42
  if (typeof args !== 'object' || Array.isArray(args)) {
42
43
  throw 'attributes must be an object';
@@ -55,6 +56,7 @@ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttr
55
56
  primaryKey: { type: 'string', required: true },
56
57
  ...writeAttributeArgs,
57
58
  },
59
+ permissions,
58
60
  implementation: async ({ primaryKey, ...attributes }) => {
59
61
  return model.update(attributes, {
60
62
  where: {
@@ -69,6 +71,7 @@ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttr
69
71
  findAttributes: { type: 'dict', required: true },
70
72
  ...writeAttributeArgs,
71
73
  },
74
+ permissions,
72
75
  implementation: async ({ findAttributes, ...writeAttributes }) => {
73
76
  // Note: this is susceptible to race condition if there is no unique index
74
77
  // on the find attributes. It's the user's responsibility to avoid
@@ -92,6 +95,7 @@ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttr
92
95
  offset: { type: 'number' },
93
96
  limit: { type: 'number' },
94
97
  },
98
+ permissions,
95
99
  implementation: async ({ offset, limit }) => {
96
100
  return model.findAll({
97
101
  attributes: readAttributes,
@@ -106,6 +110,7 @@ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttr
106
110
  arguments: {
107
111
  primaryKey: { type: 'string', required: true },
108
112
  },
113
+ permissions,
109
114
  implementation: async ({ primaryKey }) => {
110
115
  return model.findByPk(primaryKey, {
111
116
  attributes: readAttributes,
@@ -116,6 +121,7 @@ function registerModel({ rpc, model, readAttributes, writeAttributes, findByAttr
116
121
  rpc.register({
117
122
  name: `${modelName} > findBy`,
118
123
  arguments: findByAttributeArgs,
124
+ permissions,
119
125
  implementation: async (attributesValues) => {
120
126
  return model.findAll({
121
127
  where: attributesValues,
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retoolrpc",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "TypeScript package for Retool RPC",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/tryretool/retoolrpc#readme",
@@ -280,7 +280,7 @@ class Logger {
280
280
  }
281
281
  }
282
282
 
283
- const RetoolRPCVersion = '0.1.7';
283
+ const RetoolRPCVersion = '0.1.8';
284
284
 
285
285
  // AbortController was added in node v14.17.0 globally, but we need to polyfill it for older versions
286
286
  const AbortController = globalThis.AbortController || AbortControllerFallback;
@@ -5,6 +5,10 @@ type RegisterModelArgs = {
5
5
  readAttributes?: string[];
6
6
  writeAttributes?: string[];
7
7
  findByAttributes?: string[];
8
+ permissions?: {
9
+ groupNames?: string[];
10
+ userEmails?: string[];
11
+ };
8
12
  };
9
13
  export declare class MyMixinInterface {
10
14
  registerModel(args: RegisterModelArgs): void;
@@ -1,4 +1,3 @@
1
- import fetch from 'node-fetch';
2
1
  import { AgentServerError } from '../types';
3
2
  type PopQueryRequest = {
4
3
  resourceId: string;
@@ -39,8 +38,8 @@ export declare class RetoolAPI {
39
38
  apiKey: string;
40
39
  pollingTimeoutMs: number;
41
40
  });
42
- popQuery(options: PopQueryRequest): Promise<fetch.Response>;
43
- registerAgent(options: RegisterAgentRequest): Promise<fetch.Response>;
44
- postQueryResponse(options: PostQueryResponseRequest): Promise<fetch.Response>;
41
+ popQuery(options: PopQueryRequest): Promise<import("node-fetch").Response>;
42
+ registerAgent(options: RegisterAgentRequest): Promise<import("node-fetch").Response>;
43
+ postQueryResponse(options: PostQueryResponseRequest): Promise<import("node-fetch").Response>;
45
44
  }
46
45
  export {};
@@ -1 +1 @@
1
- export declare const RetoolRPCVersion = "0.1.7";
1
+ export declare const RetoolRPCVersion = "0.1.8";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retoolrpc",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "TypeScript package for Retool RPC",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/tryretool/retoolrpc#readme",
@@ -23,6 +23,16 @@
23
23
  },
24
24
  "./package.json": "./package.json"
25
25
  },
26
+ "scripts": {
27
+ "build": "yarn build:cjs && yarn build:esm",
28
+ "build:cjs": "cross-env MODE=cjs rollup -c",
29
+ "build:esm": "rollup -c",
30
+ "bumpVersion": "ts-node scripts/bumpVersion.ts",
31
+ "example": "nodemon -V -L --watch src -e ts example.ts",
32
+ "release": "yarn build && npm publish --access public",
33
+ "test": "vitest",
34
+ "test:api": "tsc --project tsconfig.json"
35
+ },
26
36
  "dependencies": {
27
37
  "abort-controller": "^3.0.0",
28
38
  "node-fetch": "^2.6",
@@ -47,15 +57,5 @@
47
57
  "tslib": "^2.1.0",
48
58
  "typescript": "5.2.2",
49
59
  "vitest": "^0.34.5"
50
- },
51
- "scripts": {
52
- "build": "yarn build:cjs && yarn build:esm",
53
- "build:cjs": "cross-env MODE=cjs rollup -c",
54
- "build:esm": "rollup -c",
55
- "bumpVersion": "ts-node scripts/bumpVersion.ts",
56
- "example": "nodemon -V -L --watch src -e ts example.ts",
57
- "release": "yarn build && npm publish --access public",
58
- "test": "vitest",
59
- "test:api": "tsc --project tsconfig.json"
60
60
  }
61
- }
61
+ }
@@ -7,6 +7,10 @@ type RegisterModelArgs = {
7
7
  readAttributes?: string[]
8
8
  writeAttributes?: string[]
9
9
  findByAttributes?: string[]
10
+ permissions?: {
11
+ groupNames?: string[]
12
+ userEmails?: string[]
13
+ }
10
14
  }
11
15
 
12
16
  export declare class MyMixinInterface {
@@ -35,6 +39,7 @@ function registerModel({
35
39
  readAttributes,
36
40
  writeAttributes,
37
41
  findByAttributes,
42
+ permissions,
38
43
  }: RegisterModelArgs & { rpc: RetoolRPC }) {
39
44
  const modelName = capitalize(model.name)
40
45
  // this will give us not just the name of the attribute, but also their type
@@ -57,6 +62,7 @@ function registerModel({
57
62
  rpc.register({
58
63
  name: `${modelName} > create`,
59
64
  arguments: writeAttributeArgs,
65
+ permissions,
60
66
  implementation: async (args) => {
61
67
  if (typeof args !== 'object' || Array.isArray(args)) {
62
68
  throw 'attributes must be an object'
@@ -76,6 +82,7 @@ function registerModel({
76
82
  primaryKey: { type: 'string', required: true },
77
83
  ...writeAttributeArgs,
78
84
  },
85
+ permissions,
79
86
  implementation: async ({ primaryKey, ...attributes }) => {
80
87
  return model.update(attributes, {
81
88
  where: {
@@ -91,6 +98,7 @@ function registerModel({
91
98
  findAttributes: { type: 'dict', required: true },
92
99
  ...writeAttributeArgs,
93
100
  },
101
+ permissions,
94
102
  implementation: async ({ findAttributes, ...writeAttributes }) => {
95
103
  // Note: this is susceptible to race condition if there is no unique index
96
104
  // on the find attributes. It's the user's responsibility to avoid
@@ -115,6 +123,7 @@ function registerModel({
115
123
  offset: { type: 'number' },
116
124
  limit: { type: 'number' },
117
125
  },
126
+ permissions,
118
127
  implementation: async ({ offset, limit }) => {
119
128
  return model.findAll({
120
129
  attributes: readAttributes,
@@ -130,6 +139,7 @@ function registerModel({
130
139
  arguments: {
131
140
  primaryKey: { type: 'string', required: true },
132
141
  },
142
+ permissions,
133
143
  implementation: async ({ primaryKey }) => {
134
144
  return model.findByPk(primaryKey, {
135
145
  attributes: readAttributes,
@@ -141,6 +151,7 @@ function registerModel({
141
151
  rpc.register({
142
152
  name: `${modelName} > findBy`,
143
153
  arguments: findByAttributeArgs,
154
+ permissions,
144
155
  implementation: async (attributesValues) => {
145
156
  return model.findAll({
146
157
  where: attributesValues,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const RetoolRPCVersion = '0.1.7'
1
+ export const RetoolRPCVersion = '0.1.8'