@tinacms/datalayer 0.0.0-f3aa146-20241112221138 → 0.0.0-f471982-20250804064407

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/dist/index.js CHANGED
@@ -17,8 +17,8 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
19
  // src/index.ts
20
- var src_exports = {};
21
- __export(src_exports, {
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
22
  AuditFileSystemBridge: () => import_graphql.AuditFileSystemBridge,
23
23
  FilesystemBridge: () => import_graphql.FilesystemBridge,
24
24
  IsomorphicBridge: () => import_graphql.IsomorphicBridge,
@@ -29,7 +29,7 @@ __export(src_exports, {
29
29
  createLocalDatabase: () => import_graphql.createLocalDatabase,
30
30
  resolve: () => import_graphql.resolve
31
31
  });
32
- module.exports = __toCommonJS(src_exports);
32
+ module.exports = __toCommonJS(index_exports);
33
33
  var import_graphql = require("@tinacms/graphql");
34
34
 
35
35
  // src/backend/index.ts
@@ -42,10 +42,10 @@ function TinaNodeBackend({
42
42
  options
43
43
  }) {
44
44
  const { initialize, isAuthorized, extraRoutes } = authProvider;
45
- initialize == null ? void 0 : initialize().catch((e) => {
45
+ initialize?.().catch((e) => {
46
46
  console.error(e);
47
47
  });
48
- const basePath = (options == null ? void 0 : options.basePath) ? `/${options.basePath.replace(/^\/?/, "").replace(/\/?$/, "")}/` : "/api/tina/";
48
+ const basePath = options?.basePath ? `/${options.basePath.replace(/^\/?/, "").replace(/\/?$/, "")}/` : "/api/tina/";
49
49
  const opts = {
50
50
  basePath
51
51
  };
@@ -64,14 +64,15 @@ function MakeNodeApiHandler({
64
64
  opts
65
65
  }) {
66
66
  const tinaBackendHandler = async (req, res) => {
67
- var _a, _b, _c, _d;
68
- const path = ((_a = req.url) == null ? void 0 : _a.startsWith("/")) ? req.url.slice(1) : req.url;
69
- const url = new URL(path, `http://${((_b = req.headers) == null ? void 0 : _b.host) || "localhost"}`);
70
- const routes = (_d = (_c = url.pathname) == null ? void 0 : _c.replace(opts.basePath, "")) == null ? void 0 : _d.split("/");
67
+ const path = req.url?.startsWith("/") ? req.url.slice(1) : req.url;
68
+ const url = new URL(path, `http://${req.headers?.host || "localhost"}`);
69
+ const routes = url.pathname?.replace(opts.basePath, "")?.split("/");
71
70
  if (typeof routes === "string") {
72
- throw new Error("Please name your next api route [...routes] not [route]");
71
+ throw new Error(
72
+ "Please name your next api route [...routes] not [route]"
73
+ );
73
74
  }
74
- if (!(routes == null ? void 0 : routes.length)) {
75
+ if (!routes?.length) {
75
76
  console.error(
76
77
  `A request was made to ${opts.basePath} but no route was found`
77
78
  );
@@ -83,7 +84,6 @@ function MakeNodeApiHandler({
83
84
  const allRoutes = {
84
85
  gql: {
85
86
  handler: async (req2, res2, _opts) => {
86
- var _a2;
87
87
  if (req2.method !== "POST") {
88
88
  res2.statusCode = 405;
89
89
  res2.write(
@@ -119,7 +119,8 @@ function MakeNodeApiHandler({
119
119
  const result = await databaseClient.request({
120
120
  query,
121
121
  variables,
122
- user: (_a2 = req2 == null ? void 0 : req2.session) == null ? void 0 : _a2.user
122
+ // @ts-ignore
123
+ user: req2?.session?.user
123
124
  });
124
125
  res2.statusCode = 200;
125
126
  res2.write(JSON.stringify(result));
@@ -145,7 +146,9 @@ function MakeNodeApiHandler({
145
146
  const isAuth = await isAuthorized(req, res);
146
147
  if (isAuth.isAuthorized === false) {
147
148
  res.statusCode = isAuth.errorCode;
148
- res.write(JSON.stringify({ error: isAuth.errorMessage || "not found" }));
149
+ res.write(
150
+ JSON.stringify({ error: isAuth.errorMessage || "not found" })
151
+ );
149
152
  res.end();
150
153
  return;
151
154
  }
package/dist/index.mjs CHANGED
@@ -45,7 +45,9 @@ function MakeNodeApiHandler({
45
45
  const url = new URL(path, `http://${req.headers?.host || "localhost"}`);
46
46
  const routes = url.pathname?.replace(opts.basePath, "")?.split("/");
47
47
  if (typeof routes === "string") {
48
- throw new Error("Please name your next api route [...routes] not [route]");
48
+ throw new Error(
49
+ "Please name your next api route [...routes] not [route]"
50
+ );
49
51
  }
50
52
  if (!routes?.length) {
51
53
  console.error(
@@ -94,6 +96,7 @@ function MakeNodeApiHandler({
94
96
  const result = await databaseClient.request({
95
97
  query,
96
98
  variables,
99
+ // @ts-ignore
97
100
  user: req2?.session?.user
98
101
  });
99
102
  res2.statusCode = 200;
@@ -120,7 +123,9 @@ function MakeNodeApiHandler({
120
123
  const isAuth = await isAuthorized(req, res);
121
124
  if (isAuth.isAuthorized === false) {
122
125
  res.statusCode = isAuth.errorCode;
123
- res.write(JSON.stringify({ error: isAuth.errorMessage || "not found" }));
126
+ res.write(
127
+ JSON.stringify({ error: isAuth.errorMessage || "not found" })
128
+ );
124
129
  res.end();
125
130
  return;
126
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/datalayer",
3
- "version": "0.0.0-f3aa146-20241112221138",
3
+ "version": "0.0.0-f471982-20250804064407",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "typings": "dist/index",
@@ -10,14 +10,14 @@
10
10
  ],
11
11
  "exports": {
12
12
  ".": {
13
+ "types": "./dist/index.d.ts",
13
14
  "import": "./dist/index.mjs",
14
- "require": "./dist/index.js",
15
- "types": "./dist/index.d.ts"
15
+ "require": "./dist/index.js"
16
16
  },
17
17
  "./dist/*": {
18
+ "types": "./dist/*.d.ts",
18
19
  "import": "./dist/*.mjs",
19
- "require": "./dist/*.js",
20
- "types": "./dist/*.d.ts"
20
+ "require": "./dist/*.js"
21
21
  }
22
22
  },
23
23
  "license": "SEE LICENSE IN LICENSE",
@@ -31,7 +31,7 @@
31
31
  ]
32
32
  },
33
33
  "dependencies": {
34
- "@tinacms/graphql": "0.0.0-f3aa146-20241112221138"
34
+ "@tinacms/graphql": "0.0.0-f471982-20250804064407"
35
35
  },
36
36
  "publishConfig": {
37
37
  "registry": "https://registry.npmjs.org"
@@ -47,15 +47,15 @@
47
47
  "@types/level": "^6.0.3",
48
48
  "@types/lodash.camelcase": "^4.3.9",
49
49
  "@types/lodash.upperfirst": "^4.3.9",
50
- "@types/node": "^22.7.4",
50
+ "@types/node": "^22.13.1",
51
51
  "@types/normalize-path": "^3.0.2",
52
52
  "@types/yup": "^0.29.14",
53
53
  "jest": "^29.7.0",
54
54
  "jest-diff": "^29.7.0",
55
55
  "jest-file-snapshot": "^0.5.0",
56
56
  "jest-matcher-utils": "^29.7.0",
57
- "typescript": "^5.6.2",
58
- "@tinacms/scripts": "1.3.0"
57
+ "typescript": "^5.7.3",
58
+ "@tinacms/scripts": "1.4.0"
59
59
  },
60
60
  "scripts": {
61
61
  "types": "pnpm tsc",