@econneq/gql-auth 1.0.2 → 1.0.5

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,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiFactory = void 0;
4
- const upload_gql_1 = require("./upload-gql");
5
- const utils_1 = require("./utils");
6
- const ApiFactory = async (options) => {
1
+ import { uploadGraphQLMutation } from "./upload-gql";
2
+ import { removeEmptyFields } from "./utils";
3
+ export const ApiFactory = async (options) => {
7
4
  const { newData, editData, mutationName, modelName, successField = "title", query, router, params, reload = true, redirect, redirectPath, returnResponseField = false, returnResponseObject = false, getFileMap, token, config, onAlert } = options;
8
5
  const items = Array.isArray(newData || editData) ? (newData || editData) : [(newData || editData)];
9
6
  const successMessages = [];
@@ -12,9 +9,9 @@ const ApiFactory = async (options) => {
12
9
  for (let res of items) {
13
10
  try {
14
11
  console.log("launching e-conneq/auth-gql ......");
15
- const response = await (0, upload_gql_1.uploadGraphQLMutation)({
12
+ const response = await uploadGraphQLMutation({
16
13
  query: query.loc?.source.body || "",
17
- variables: (0, utils_1.removeEmptyFields)(res),
14
+ variables: removeEmptyFields(res),
18
15
  fileMap: getFileMap ? getFileMap(res) : {},
19
16
  params, // Pass domain params for multi-tenancy
20
17
  token,
@@ -58,7 +55,6 @@ const ApiFactory = async (options) => {
58
55
  });
59
56
  }
60
57
  };
61
- exports.ApiFactory = ApiFactory;
62
58
  // Internal Helper for Error Parsing
63
59
  const handleGraphQLErrors = (errors, errorList) => {
64
60
  errors.forEach(error => {
package/dist/client.js CHANGED
@@ -1,13 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = getApolloClient;
7
1
  // src/client.ts
8
- const client_1 = require("@apollo/client");
9
- const js_cookie_1 = __importDefault(require("js-cookie"));
10
- async function getApolloClient(options, domain, config) {
2
+ import { ApolloClient, InMemoryCache, HttpLink } from '@apollo/client';
3
+ import Cookies from "js-cookie";
4
+ export default async function getApolloClient(options, domain, config) {
11
5
  if (!config)
12
6
  throw new Error("Configuration is required for getApolloClient");
13
7
  const isServer = typeof window === "undefined";
@@ -23,7 +17,7 @@ async function getApolloClient(options, domain, config) {
23
17
  : `${protocol}${NoDomainRootApi}`;
24
18
  const uri = `${baseUrl}/graphql/`;
25
19
  // 3. Header Logic
26
- const csrfToken = options?.csrfToken || (!isServer ? js_cookie_1.default.get("csrftoken") : "");
20
+ const csrfToken = options?.csrfToken || (!isServer ? Cookies.get("csrftoken") : "");
27
21
  const headers = {
28
22
  'Content-Type': 'application/json',
29
23
  'X-API-KEY': apiKey,
@@ -36,13 +30,13 @@ async function getApolloClient(options, domain, config) {
36
30
  }),
37
31
  'Referer': baseUrl,
38
32
  };
39
- return new client_1.ApolloClient({
40
- link: new client_1.HttpLink({
33
+ return new ApolloClient({
34
+ link: new HttpLink({
41
35
  uri,
42
36
  fetch, // Next.js polyfills fetch on server automatically
43
37
  headers,
44
38
  }),
45
- cache: new client_1.InMemoryCache(),
39
+ cache: new InMemoryCache(),
46
40
  defaultOptions: {
47
41
  mutate: { fetchPolicy: 'no-cache' },
48
42
  query: { fetchPolicy: 'no-cache' },
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { ReactNode } from "react";
2
- export { default as getApolloClient } from './client';
3
- export { queryServerGraphQL } from './query-server';
4
- export { ApiFactory } from './api-factory';
5
- export { uploadGraphQLMutation } from './upload-gql';
2
+ export { queryServerGraphQL } from './query-server.js';
3
+ export { ApiFactory } from './api-factory.js';
4
+ export { uploadGraphQLMutation } from './upload-gql.js';
6
5
  export type ConfigType = {
7
6
  protocol: string;
8
7
  RootApi: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OA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U,EACxE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,kBAAkB,GAClG,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,30 +1,9 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateFormFields = exports.Alert = exports.getTimeAgo = exports.getStoredFont = exports.getLanguage = exports.getTemplate = exports.getToken = exports.getUser = exports.formatText = exports.decodeUrlID = exports.errorLog = exports.removeEmptyFields = exports.capitalizeEachWord = exports.uploadGraphQLMutation = exports.ApiFactory = exports.queryServerGraphQL = exports.getApolloClient = void 0;
7
1
  // 1. Export the Core Functions
8
- var client_1 = require("./client");
9
- Object.defineProperty(exports, "getApolloClient", { enumerable: true, get: function () { return __importDefault(client_1).default; } });
10
- var query_server_1 = require("./query-server");
11
- Object.defineProperty(exports, "queryServerGraphQL", { enumerable: true, get: function () { return query_server_1.queryServerGraphQL; } });
12
- var api_factory_1 = require("./api-factory");
13
- Object.defineProperty(exports, "ApiFactory", { enumerable: true, get: function () { return api_factory_1.ApiFactory; } });
14
- var upload_gql_1 = require("./upload-gql");
15
- Object.defineProperty(exports, "uploadGraphQLMutation", { enumerable: true, get: function () { return upload_gql_1.uploadGraphQLMutation; } });
2
+ // export { queryServerGraphQL } from './query-server';
3
+ // export { ApiFactory } from './api-factory';
4
+ // export { uploadGraphQLMutation } from './upload-gql';
5
+ export { queryServerGraphQL } from './query-server.js';
6
+ export { ApiFactory } from './api-factory.js';
7
+ export { uploadGraphQLMutation } from './upload-gql.js';
16
8
  // 3. Export Helper Utilities (Optional)
17
- var utils_1 = require("./utils");
18
- Object.defineProperty(exports, "capitalizeEachWord", { enumerable: true, get: function () { return utils_1.capitalizeEachWord; } });
19
- Object.defineProperty(exports, "removeEmptyFields", { enumerable: true, get: function () { return utils_1.removeEmptyFields; } });
20
- Object.defineProperty(exports, "errorLog", { enumerable: true, get: function () { return utils_1.errorLog; } });
21
- Object.defineProperty(exports, "decodeUrlID", { enumerable: true, get: function () { return utils_1.decodeUrlID; } });
22
- Object.defineProperty(exports, "formatText", { enumerable: true, get: function () { return utils_1.formatText; } });
23
- Object.defineProperty(exports, "getUser", { enumerable: true, get: function () { return utils_1.getUser; } });
24
- Object.defineProperty(exports, "getToken", { enumerable: true, get: function () { return utils_1.getToken; } });
25
- Object.defineProperty(exports, "getTemplate", { enumerable: true, get: function () { return utils_1.getTemplate; } });
26
- Object.defineProperty(exports, "getLanguage", { enumerable: true, get: function () { return utils_1.getLanguage; } });
27
- Object.defineProperty(exports, "getStoredFont", { enumerable: true, get: function () { return utils_1.getStoredFont; } });
28
- Object.defineProperty(exports, "getTimeAgo", { enumerable: true, get: function () { return utils_1.getTimeAgo; } });
29
- Object.defineProperty(exports, "Alert", { enumerable: true, get: function () { return utils_1.Alert; } });
30
- Object.defineProperty(exports, "validateFormFields", { enumerable: true, get: function () { return utils_1.validateFormFields; } });
9
+ export { capitalizeEachWord, removeEmptyFields, errorLog, decodeUrlID, formatText, getUser, getToken, getTemplate, getLanguage, getStoredFont, getTimeAgo, Alert, validateFormFields, } from './utils';
@@ -1 +1 @@
1
- {"version":3,"file":"query-server.d.ts","sourceRoot":"","sources":["../src/query-server.ts"],"names":[],"mappings":"AAIA,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,GAAG,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,GAAG,EAAE,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,EAChD,KAAK,EACL,SAAc,EACd,MAAM,EACN,MAAM,GACP,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CA8BrC"}
1
+ {"version":3,"file":"query-server.d.ts","sourceRoot":"","sources":["../src/query-server.ts"],"names":[],"mappings":"AAKA,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,GAAG,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,GAAG,EAAE,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,EAChD,KAAK,EACL,SAAc,EACd,MAAM,EACN,MAAM,GACP,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CA8BrC"}
@@ -1,22 +1,17 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.queryServerGraphQL = queryServerGraphQL;
7
1
  // src/server-query.ts
8
- const headers_1 = require("next/headers");
9
- const client_1 = __importDefault(require("./client"));
10
- async function queryServerGraphQL({ query, variables = {}, domain, config, }) {
2
+ 'use server';
3
+ import { cookies } from 'next/headers';
4
+ import getApolloClient from './client';
5
+ export async function queryServerGraphQL({ query, variables = {}, domain, config, }) {
11
6
  try {
12
7
  // 1. Get server-side cookies
13
- const cookieStore = await (0, headers_1.cookies)();
8
+ const cookieStore = await cookies();
14
9
  const cookieString = cookieStore.toString();
15
10
  // 2. Call getApolloClient with the correct 3 arguments:
16
11
  // Arg 1: options (cookies)
17
12
  // Arg 2: domain (subdomain string)
18
13
  // Arg 3: config (URLs and Subdomain array)
19
- const client = await (0, client_1.default)({ cookie: cookieString }, domain, config);
14
+ const client = await getApolloClient({ cookie: cookieString }, domain, config);
20
15
  if (!client)
21
16
  return null;
22
17
  const result = await client.query({
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadGraphQLMutation = uploadGraphQLMutation;
4
- async function uploadGraphQLMutation({ query, variables, fileMap, token, params, config }) {
1
+ export async function uploadGraphQLMutation({ query, variables, fileMap, token, params, config }) {
5
2
  const { protocol, RootApi, NoDomainRootApi, Subdomains, apiKey } = config;
6
3
  const formData = new FormData();
7
4
  const updatedVariables = { ...variables };
package/dist/utils.js CHANGED
@@ -1,14 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.formatText = exports.lastYears = exports.validateFormFields = exports.Alert = exports.removeEmptyFields = exports.decodeUrlID = exports.getTemplate = exports.getLanguage = exports.getTimeAgo = exports.getStoredFont = exports.getUser = exports.getToken = exports.errorLog = exports.capitalizeEachWord = void 0;
7
- exports.getAcademicYear = getAcademicYear;
8
- const sweetalert2_1 = __importDefault(require("sweetalert2"));
9
- const js_cookie_1 = __importDefault(require("js-cookie"));
10
- const jwt_decode_1 = require("jwt-decode");
11
- const capitalizeEachWord = (str) => {
1
+ import Swal from "sweetalert2";
2
+ import Cookies from "js-cookie";
3
+ import { jwtDecode } from "jwt-decode";
4
+ export const capitalizeEachWord = (str) => {
12
5
  if (!str)
13
6
  return ''; // Handle empty or null strings
14
7
  return str
@@ -16,8 +9,7 @@ const capitalizeEachWord = (str) => {
16
9
  .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
17
10
  .join(' ');
18
11
  };
19
- exports.capitalizeEachWord = capitalizeEachWord;
20
- const errorLog = (err, show) => {
12
+ export const errorLog = (err, show) => {
21
13
  let mes = "An unknown error occurred";
22
14
  if (typeof err === "string")
23
15
  mes = err;
@@ -35,7 +27,7 @@ const errorLog = (err, show) => {
35
27
  else if (err?.message)
36
28
  mes = err.message;
37
29
  if (show) {
38
- sweetalert2_1.default.fire({
30
+ Swal.fire({
39
31
  title: mes,
40
32
  icon: 'error',
41
33
  timer: 3000,
@@ -45,23 +37,20 @@ const errorLog = (err, show) => {
45
37
  }
46
38
  return mes;
47
39
  };
48
- exports.errorLog = errorLog;
49
40
  const currentYear = new Date().getFullYear();
50
- const getToken = () => {
41
+ export const getToken = () => {
51
42
  if (typeof window === "undefined") {
52
43
  return null;
53
44
  }
54
- return js_cookie_1.default.get("token") || localStorage.getItem("token");
45
+ return Cookies.get("token") || localStorage.getItem("token");
55
46
  };
56
- exports.getToken = getToken;
57
- const getUser = () => {
47
+ export const getUser = () => {
58
48
  // const token = typeof window !== 'undefined' ? localStorage.getItem("token") : null;
59
- const token = (0, exports.getToken)();
60
- const user = token ? (0, jwt_decode_1.jwtDecode)(token) : null;
49
+ const token = getToken();
50
+ const user = token ? jwtDecode(token) : null;
61
51
  return user;
62
52
  };
63
- exports.getUser = getUser;
64
- const getStoredFont = (FONTS) => {
53
+ export const getStoredFont = (FONTS) => {
65
54
  if (typeof window === "undefined")
66
55
  return FONTS[0]; // Default for SSR
67
56
  const up = localStorage.getItem("user-pref");
@@ -70,8 +59,7 @@ const getStoredFont = (FONTS) => {
70
59
  const fontIndex = parseInt(up[1]) - 1;
71
60
  return FONTS[fontIndex] || FONTS[5];
72
61
  };
73
- exports.getStoredFont = getStoredFont;
74
- const getTimeAgo = (dateStr, type) => {
62
+ export const getTimeAgo = (dateStr, type) => {
75
63
  if (!dateStr)
76
64
  return "";
77
65
  const now = new Date();
@@ -120,8 +108,7 @@ const getTimeAgo = (dateStr, type) => {
120
108
  return `${months} month${months > 1 ? "s" : ""} left`;
121
109
  return `${years} year${years > 1 ? "s" : ""} left`;
122
110
  };
123
- exports.getTimeAgo = getTimeAgo;
124
- const getLanguage = () => {
111
+ export const getLanguage = () => {
125
112
  if (typeof window === "undefined")
126
113
  return "en";
127
114
  const up = localStorage.getItem("user-pref");
@@ -130,8 +117,7 @@ const getLanguage = () => {
130
117
  const langNumber = parseInt(up[0]);
131
118
  return langNumber === 1 ? "en" : "fr";
132
119
  };
133
- exports.getLanguage = getLanguage;
134
- const getTemplate = () => {
120
+ export const getTemplate = () => {
135
121
  if (typeof window === "undefined")
136
122
  return 1;
137
123
  const up = localStorage.getItem("user-pref");
@@ -139,14 +125,12 @@ const getTemplate = () => {
139
125
  return 1;
140
126
  return parseInt(up[2]);
141
127
  };
142
- exports.getTemplate = getTemplate;
143
- const decodeUrlID = (urlID) => {
128
+ export const decodeUrlID = (urlID) => {
144
129
  const base64DecodedString = decodeURIComponent(urlID); // Decodes %3D%3D to ==
145
130
  const id = Buffer.from(base64DecodedString, 'base64').toString('utf-8'); // Decoding from base64
146
131
  return id.split(":")[1];
147
132
  };
148
- exports.decodeUrlID = decodeUrlID;
149
- function getAcademicYear() {
133
+ export function getAcademicYear() {
150
134
  const today = new Date();
151
135
  const year = today.getFullYear();
152
136
  const month = today.getMonth(); // 0 = January, 7 = August
@@ -157,7 +141,7 @@ function getAcademicYear() {
157
141
  return `${year}/${year + 1}`;
158
142
  }
159
143
  }
160
- const removeEmptyFields = (obj) => {
144
+ export const removeEmptyFields = (obj) => {
161
145
  const newObj = {};
162
146
  for (const key in obj) {
163
147
  // Keep File objects and non-empty values
@@ -168,18 +152,16 @@ const removeEmptyFields = (obj) => {
168
152
  }
169
153
  return newObj;
170
154
  };
171
- exports.removeEmptyFields = removeEmptyFields;
172
- const Alert = ({ title, duration, status = true }) => {
173
- sweetalert2_1.default.fire({
174
- title: (0, exports.capitalizeEachWord)(title),
155
+ export const Alert = ({ title, duration, status = true }) => {
156
+ Swal.fire({
157
+ title: capitalizeEachWord(title),
175
158
  timer: duration,
176
159
  timerProgressBar: true,
177
160
  showConfirmButton: false,
178
161
  icon: status ? 'success' : 'error',
179
162
  });
180
163
  };
181
- exports.Alert = Alert;
182
- const validateFormFields = (formData, currentStepFields) => {
164
+ export const validateFormFields = (formData, currentStepFields) => {
183
165
  const newErrors = {};
184
166
  // 1. Flatten the fields from all rows in the step
185
167
  const fieldsToValidate = currentStepFields.flatMap(row => row.fields);
@@ -191,7 +173,7 @@ const validateFormFields = (formData, currentStepFields) => {
191
173
  const value = formData[field.name];
192
174
  // 3. Check Required
193
175
  if (field.required && (!value || value.toString().trim() === "")) {
194
- newErrors[field.name] = `${(0, exports.capitalizeEachWord)(field.label)} is required`;
176
+ newErrors[field.name] = `${capitalizeEachWord(field.label)} is required`;
195
177
  // return;
196
178
  }
197
179
  // 4. Check Type (Email)
@@ -223,15 +205,13 @@ const validateFormFields = (formData, currentStepFields) => {
223
205
  });
224
206
  return newErrors;
225
207
  };
226
- exports.validateFormFields = validateFormFields;
227
- const lastYears = (number) => {
208
+ export const lastYears = (number) => {
228
209
  return Array.from({ length: number }, (_, i) => ({
229
210
  value: (currentYear - i).toString(),
230
211
  label: (currentYear - i).toString()
231
212
  })).sort((a, b) => Number(b.value) - Number(a.value));
232
213
  };
233
- exports.lastYears = lastYears;
234
- const formatText = (text) => {
214
+ export const formatText = (text) => {
235
215
  return text;
236
216
  if (!text || typeof text !== "string")
237
217
  return "";
@@ -275,4 +255,3 @@ const formatText = (text) => {
275
255
  })
276
256
  .join("");
277
257
  };
278
- exports.formatText = formatText;
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@econneq/gql-auth",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
+ "type": "module",
4
5
  "main": "./dist/index.js",
5
- "module": "./dist/index.mjs",
6
+ "module": "./dist/index.js",
6
7
  "types": "./dist/index.d.ts",
7
8
  "scripts": {
8
9
  "build": "tsc",
@@ -11,7 +12,7 @@
11
12
  "exports": {
12
13
  ".": {
13
14
  "types": "./dist/index.d.ts",
14
- "import": "./dist/index.mjs",
15
+ "import": "./dist/index.js",
15
16
  "require": "./dist/index.js"
16
17
  }
17
18
  },