codebase-models 3.0.7 → 3.0.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.
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
import mongoose, { Document } from "mongoose";
|
|
26
|
+
export declare enum ProviderType {
|
|
27
|
+
SHOPIFY = "shopify",
|
|
28
|
+
BIGQUERY = "bigquery",
|
|
29
|
+
GOOGLE_ANALYTICS = "google_analytics",
|
|
30
|
+
GOOGLE_TAG_MANAGER = "google_tag_manager",
|
|
31
|
+
GOOGLE_ADS = "google_ads",
|
|
32
|
+
GOOGLE_SEARCH_CONSOLE = "google_search_console",
|
|
33
|
+
GOOGLE_SHEETS = "google_sheets",
|
|
34
|
+
GOOGLE_DOCS = "google_docs",
|
|
35
|
+
GOOGLE_DRIVE = "google_drive",
|
|
36
|
+
GOOGLE_MAIL = "google_mail",
|
|
37
|
+
GOOGLE_CALENDAR = "google_calendar"
|
|
38
|
+
}
|
|
39
|
+
export interface IShopifyMetadata {
|
|
40
|
+
apiKey: string;
|
|
41
|
+
apiSecretKey: string;
|
|
42
|
+
hostName: string;
|
|
43
|
+
apiVersion?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface IBigQueryMetadata {
|
|
46
|
+
projectId: string;
|
|
47
|
+
credentials: {
|
|
48
|
+
type?: string;
|
|
49
|
+
project_id?: string;
|
|
50
|
+
private_key_id?: string;
|
|
51
|
+
private_key?: string;
|
|
52
|
+
client_email?: string;
|
|
53
|
+
client_id?: string;
|
|
54
|
+
auth_uri?: string;
|
|
55
|
+
token_uri?: string;
|
|
56
|
+
auth_provider_x509_cert_url?: string;
|
|
57
|
+
client_x509_cert_url?: string;
|
|
58
|
+
};
|
|
59
|
+
datasetId?: string;
|
|
60
|
+
location?: string;
|
|
61
|
+
}
|
|
62
|
+
export type ProviderMetadata = IShopifyMetadata | IBigQueryMetadata | mongoose.Schema.Types.Mixed;
|
|
63
|
+
export interface IProvider extends Document {
|
|
64
|
+
iid: string;
|
|
65
|
+
name: string;
|
|
66
|
+
providerType: ProviderType | string;
|
|
67
|
+
client: mongoose.Schema.Types.ObjectId;
|
|
68
|
+
user: mongoose.Schema.Types.ObjectId;
|
|
69
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
70
|
+
metadata?: ProviderMetadata;
|
|
71
|
+
active: boolean;
|
|
72
|
+
}
|
|
73
|
+
declare const Provider: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
74
|
+
export default Provider;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ProviderType = void 0;
|
|
27
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
|
28
|
+
const constant_1 = require("../constant");
|
|
29
|
+
// Provider type enum
|
|
30
|
+
var ProviderType;
|
|
31
|
+
(function (ProviderType) {
|
|
32
|
+
ProviderType["SHOPIFY"] = "shopify";
|
|
33
|
+
ProviderType["BIGQUERY"] = "bigquery";
|
|
34
|
+
ProviderType["GOOGLE_ANALYTICS"] = "google_analytics";
|
|
35
|
+
ProviderType["GOOGLE_TAG_MANAGER"] = "google_tag_manager";
|
|
36
|
+
ProviderType["GOOGLE_ADS"] = "google_ads";
|
|
37
|
+
ProviderType["GOOGLE_SEARCH_CONSOLE"] = "google_search_console";
|
|
38
|
+
ProviderType["GOOGLE_SHEETS"] = "google_sheets";
|
|
39
|
+
ProviderType["GOOGLE_DOCS"] = "google_docs";
|
|
40
|
+
ProviderType["GOOGLE_DRIVE"] = "google_drive";
|
|
41
|
+
ProviderType["GOOGLE_MAIL"] = "google_mail";
|
|
42
|
+
ProviderType["GOOGLE_CALENDAR"] = "google_calendar";
|
|
43
|
+
// Add more provider types as needed
|
|
44
|
+
})(ProviderType || (exports.ProviderType = ProviderType = {}));
|
|
45
|
+
const ProviderSchema = new mongoose_1.Schema({
|
|
46
|
+
iid: {
|
|
47
|
+
type: String,
|
|
48
|
+
required: true,
|
|
49
|
+
trim: true,
|
|
50
|
+
unique: true,
|
|
51
|
+
default: () => (0, constant_1.generateRandomIID)(), // ✅ auto-generate always
|
|
52
|
+
},
|
|
53
|
+
name: {
|
|
54
|
+
type: String,
|
|
55
|
+
required: true,
|
|
56
|
+
trim: true,
|
|
57
|
+
},
|
|
58
|
+
providerType: {
|
|
59
|
+
type: String,
|
|
60
|
+
required: true,
|
|
61
|
+
enum: Object.values(ProviderType),
|
|
62
|
+
lowercase: true,
|
|
63
|
+
trim: true,
|
|
64
|
+
},
|
|
65
|
+
client: {
|
|
66
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
67
|
+
ref: "client",
|
|
68
|
+
required: true,
|
|
69
|
+
},
|
|
70
|
+
user: {
|
|
71
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
72
|
+
ref: "user",
|
|
73
|
+
required: true,
|
|
74
|
+
},
|
|
75
|
+
organizationId: {
|
|
76
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
77
|
+
ref: "organization",
|
|
78
|
+
default: null,
|
|
79
|
+
},
|
|
80
|
+
metadata: {
|
|
81
|
+
type: mongoose_1.default.Schema.Types.Mixed,
|
|
82
|
+
default: null,
|
|
83
|
+
// Provider-specific validation can be added via pre-save hooks if needed
|
|
84
|
+
},
|
|
85
|
+
active: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: true,
|
|
88
|
+
},
|
|
89
|
+
}, {
|
|
90
|
+
timestamps: true,
|
|
91
|
+
});
|
|
92
|
+
// Indexes for common query patterns
|
|
93
|
+
ProviderSchema.index({ providerType: 1, client: 1 });
|
|
94
|
+
ProviderSchema.index({ providerType: 1, active: 1 });
|
|
95
|
+
ProviderSchema.index({ client: 1, active: 1 });
|
|
96
|
+
ProviderSchema.index({ user: 1 });
|
|
97
|
+
const Provider = mongoose_1.default.models.provider || (0, mongoose_1.model)("provider", ProviderSchema);
|
|
98
|
+
exports.default = Provider;
|
package/dist/src/models/User.js
CHANGED
|
@@ -37,9 +37,9 @@ const UserSchema = new mongoose_1.Schema({
|
|
|
37
37
|
twoFactor: { type: Boolean, default: false },
|
|
38
38
|
emailVerified: { type: Boolean, default: false },
|
|
39
39
|
resetLink: String,
|
|
40
|
-
bigqueryToken: String,
|
|
41
|
-
expirybqToken: String,
|
|
42
|
-
refreshToken: String,
|
|
40
|
+
// bigqueryToken: String,
|
|
41
|
+
// expirybqToken: String,
|
|
42
|
+
// refreshToken: String,
|
|
43
43
|
isSSOUser: { type: Boolean, default: false },
|
|
44
44
|
role: { type: [mongoose_1.default.Schema.Types.ObjectId], ref: "role", default: null },
|
|
45
45
|
}, { timestamps: true });
|
package/package.json
CHANGED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
|
+
import { generateRandomIID } from "../constant";
|
|
3
|
+
|
|
4
|
+
// Provider type enum
|
|
5
|
+
export enum ProviderType {
|
|
6
|
+
SHOPIFY = "shopify",
|
|
7
|
+
BIGQUERY = "bigquery",
|
|
8
|
+
GOOGLE_ANALYTICS = "google_analytics",
|
|
9
|
+
GOOGLE_TAG_MANAGER = "google_tag_manager",
|
|
10
|
+
GOOGLE_ADS = "google_ads",
|
|
11
|
+
GOOGLE_SEARCH_CONSOLE = "google_search_console",
|
|
12
|
+
GOOGLE_SHEETS = "google_sheets",
|
|
13
|
+
GOOGLE_DOCS = "google_docs",
|
|
14
|
+
GOOGLE_DRIVE = "google_drive",
|
|
15
|
+
GOOGLE_MAIL = "google_mail",
|
|
16
|
+
GOOGLE_CALENDAR = "google_calendar",
|
|
17
|
+
// Add more provider types as needed
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Shopify provider metadata interface
|
|
21
|
+
export interface IShopifyMetadata {
|
|
22
|
+
apiKey: string;
|
|
23
|
+
apiSecretKey: string;
|
|
24
|
+
hostName: string;
|
|
25
|
+
apiVersion?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Google BigQuery provider metadata interface
|
|
29
|
+
export interface IBigQueryMetadata {
|
|
30
|
+
projectId: string;
|
|
31
|
+
credentials: {
|
|
32
|
+
type?: string;
|
|
33
|
+
project_id?: string;
|
|
34
|
+
private_key_id?: string;
|
|
35
|
+
private_key?: string;
|
|
36
|
+
client_email?: string;
|
|
37
|
+
client_id?: string;
|
|
38
|
+
auth_uri?: string;
|
|
39
|
+
token_uri?: string;
|
|
40
|
+
auth_provider_x509_cert_url?: string;
|
|
41
|
+
client_x509_cert_url?: string;
|
|
42
|
+
};
|
|
43
|
+
datasetId?: string;
|
|
44
|
+
location?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Union type for all provider metadata
|
|
48
|
+
export type ProviderMetadata = IShopifyMetadata | IBigQueryMetadata | mongoose.Schema.Types.Mixed;
|
|
49
|
+
|
|
50
|
+
export interface IProvider extends Document {
|
|
51
|
+
iid: string;
|
|
52
|
+
name: string;
|
|
53
|
+
providerType: ProviderType | string;
|
|
54
|
+
client: mongoose.Schema.Types.ObjectId;
|
|
55
|
+
user: mongoose.Schema.Types.ObjectId;
|
|
56
|
+
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
57
|
+
metadata?: ProviderMetadata;
|
|
58
|
+
active: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const ProviderSchema = new Schema<IProvider>(
|
|
62
|
+
{
|
|
63
|
+
iid: {
|
|
64
|
+
type: String,
|
|
65
|
+
required: true,
|
|
66
|
+
trim: true,
|
|
67
|
+
unique: true,
|
|
68
|
+
default: () => generateRandomIID(), // ✅ auto-generate always
|
|
69
|
+
},
|
|
70
|
+
name: {
|
|
71
|
+
type: String,
|
|
72
|
+
required: true,
|
|
73
|
+
trim: true,
|
|
74
|
+
},
|
|
75
|
+
providerType: {
|
|
76
|
+
type: String,
|
|
77
|
+
required: true,
|
|
78
|
+
enum: Object.values(ProviderType),
|
|
79
|
+
lowercase: true,
|
|
80
|
+
trim: true,
|
|
81
|
+
},
|
|
82
|
+
client: {
|
|
83
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
84
|
+
ref: "client",
|
|
85
|
+
required: true,
|
|
86
|
+
},
|
|
87
|
+
user: {
|
|
88
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
89
|
+
ref: "user",
|
|
90
|
+
required: true,
|
|
91
|
+
},
|
|
92
|
+
organizationId: {
|
|
93
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
94
|
+
ref: "organization",
|
|
95
|
+
default: null,
|
|
96
|
+
},
|
|
97
|
+
metadata: {
|
|
98
|
+
type: mongoose.Schema.Types.Mixed,
|
|
99
|
+
default: null,
|
|
100
|
+
// Provider-specific validation can be added via pre-save hooks if needed
|
|
101
|
+
},
|
|
102
|
+
active: {
|
|
103
|
+
type: Boolean,
|
|
104
|
+
default: true,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
timestamps: true,
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// Indexes for common query patterns
|
|
113
|
+
ProviderSchema.index({ providerType: 1, client: 1 });
|
|
114
|
+
ProviderSchema.index({ providerType: 1, active: 1 });
|
|
115
|
+
ProviderSchema.index({ client: 1, active: 1 });
|
|
116
|
+
ProviderSchema.index({ user: 1 });
|
|
117
|
+
|
|
118
|
+
const Provider = mongoose.models.provider || model<IProvider>("provider", ProviderSchema);
|
|
119
|
+
|
|
120
|
+
export default Provider;
|
package/src/models/User.ts
CHANGED
|
@@ -13,9 +13,9 @@ export interface IUser extends Document {
|
|
|
13
13
|
twoFactor: boolean;
|
|
14
14
|
emailVerified: boolean;
|
|
15
15
|
resetLink: string;
|
|
16
|
-
bigqueryToken: string;
|
|
17
|
-
expirybqToken: string;
|
|
18
|
-
refreshToken: string;
|
|
16
|
+
// bigqueryToken: string;
|
|
17
|
+
// expirybqToken: string;
|
|
18
|
+
// refreshToken: string;
|
|
19
19
|
createdAt: Date;
|
|
20
20
|
updatedAt: Date;
|
|
21
21
|
isSSOUser: boolean;
|
|
@@ -35,9 +35,9 @@ const UserSchema = new Schema<IUser>(
|
|
|
35
35
|
twoFactor: { type: Boolean, default: false },
|
|
36
36
|
emailVerified: { type: Boolean, default: false },
|
|
37
37
|
resetLink: String,
|
|
38
|
-
bigqueryToken: String,
|
|
39
|
-
expirybqToken: String,
|
|
40
|
-
refreshToken: String,
|
|
38
|
+
// bigqueryToken: String,
|
|
39
|
+
// expirybqToken: String,
|
|
40
|
+
// refreshToken: String,
|
|
41
41
|
isSSOUser: { type: Boolean, default: false },
|
|
42
42
|
role: { type: [mongoose.Schema.Types.ObjectId], ref: "role", default: null },
|
|
43
43
|
},
|