@dereekb/firebase 10.0.18 → 10.0.19
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/index.cjs.js +163 -20
- package/index.esm.js +200 -22
- package/package.json +1 -1
- package/src/lib/client/function/model.function.factory.d.ts +17 -0
- package/src/lib/common/model/function.d.ts +82 -11
- package/test/CHANGELOG.md +4 -0
- package/test/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -6796,54 +6796,190 @@ function lazyFirebaseFunctionsFactory(configMap) {
|
|
|
6796
6796
|
};
|
|
6797
6797
|
}
|
|
6798
6798
|
|
|
6799
|
+
/**
|
|
6800
|
+
* Creates a OnCallTypedModelParamsFunction
|
|
6801
|
+
*
|
|
6802
|
+
* @param call
|
|
6803
|
+
* @returns
|
|
6804
|
+
*/
|
|
6805
|
+
function onCallTypedModelParamsFunction(call) {
|
|
6806
|
+
return (modelTypeInput, data, specifier) => {
|
|
6807
|
+
const modelType = typeof modelTypeInput === 'string' ? modelTypeInput : modelTypeInput.modelType;
|
|
6808
|
+
if (!modelType) {
|
|
6809
|
+
throw new Error('modelType is required.');
|
|
6810
|
+
}
|
|
6811
|
+
const result = {
|
|
6812
|
+
call,
|
|
6813
|
+
modelType,
|
|
6814
|
+
data
|
|
6815
|
+
};
|
|
6816
|
+
if (specifier != null) {
|
|
6817
|
+
result.specifier = specifier;
|
|
6818
|
+
}
|
|
6819
|
+
return result;
|
|
6820
|
+
};
|
|
6821
|
+
}
|
|
6822
|
+
/**
|
|
6823
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'create'
|
|
6824
|
+
*/
|
|
6825
|
+
const onCallCreateModelParams = onCallTypedModelParamsFunction('create');
|
|
6826
|
+
/**
|
|
6827
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'read'
|
|
6828
|
+
*/
|
|
6829
|
+
const onCallReadModelParams = onCallTypedModelParamsFunction('read');
|
|
6830
|
+
/**
|
|
6831
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'update'
|
|
6832
|
+
*/
|
|
6833
|
+
const onCallUpdateModelParams = onCallTypedModelParamsFunction('update');
|
|
6834
|
+
/**
|
|
6835
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'delete'
|
|
6836
|
+
*/
|
|
6837
|
+
const onCallDeleteModelParams = onCallTypedModelParamsFunction('delete');
|
|
6799
6838
|
/**
|
|
6800
6839
|
* Creates a OnCallTypedModelParams
|
|
6801
6840
|
*
|
|
6841
|
+
* @deprecated use onCallTypedModelParamsFunction instead.
|
|
6842
|
+
*
|
|
6802
6843
|
* @param modelType
|
|
6803
6844
|
* @param data
|
|
6804
6845
|
* @returns
|
|
6805
6846
|
*/
|
|
6806
|
-
function onCallTypedModelParams(modelTypeInput, data, specifier) {
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6847
|
+
function onCallTypedModelParams(modelTypeInput, data, specifier, call) {
|
|
6848
|
+
return onCallTypedModelParamsFunction(call)(modelTypeInput, data, specifier);
|
|
6849
|
+
}
|
|
6850
|
+
/**
|
|
6851
|
+
* Key used on the front-end and backend that refers to the call function.
|
|
6852
|
+
*/
|
|
6853
|
+
const CALL_MODEL_APP_FUNCTION_KEY = 'callModel';
|
|
6854
|
+
function onCallCreateModelResultWithDocs(result) {
|
|
6855
|
+
return onCallCreateModelResult(util.asArray(result).map(x => x.documentRef.path));
|
|
6856
|
+
}
|
|
6857
|
+
function onCallCreateModelResult(modelKeys) {
|
|
6858
|
+
return {
|
|
6859
|
+
modelKeys: util.asArray(modelKeys)
|
|
6814
6860
|
};
|
|
6815
|
-
if (specifier != null) {
|
|
6816
|
-
result.specifier = specifier;
|
|
6817
|
-
}
|
|
6818
|
-
return result;
|
|
6819
6861
|
}
|
|
6862
|
+
// MARK: Compat
|
|
6820
6863
|
/**
|
|
6821
6864
|
* Key used on the front-end and backend that refers to a specific function for creating models.
|
|
6865
|
+
*
|
|
6866
|
+
* @deprecated Replaced by the callModel function.
|
|
6822
6867
|
*/
|
|
6823
6868
|
const CREATE_MODEL_APP_FUNCTION_KEY = 'createModel';
|
|
6824
6869
|
/**
|
|
6825
6870
|
* Key used on the front-end and backend that refers to a specific function for reading models.
|
|
6871
|
+
*
|
|
6872
|
+
* @deprecated Replaced by the callModel function.
|
|
6826
6873
|
*/
|
|
6827
6874
|
const READ_MODEL_APP_FUNCTION_KEY = 'readModel';
|
|
6828
6875
|
/**
|
|
6829
6876
|
* Key used on the front-end and backend that refers to a specific function for updating models.
|
|
6877
|
+
*
|
|
6878
|
+
* @deprecated Replaced by the callModel function.
|
|
6830
6879
|
*/
|
|
6831
6880
|
const UPDATE_MODEL_APP_FUNCTION_KEY = 'updateModel';
|
|
6832
6881
|
/**
|
|
6833
6882
|
* Key used on the front-end and backend that refers to a specific function for deleting models.
|
|
6883
|
+
*
|
|
6884
|
+
* @deprecated Replaced by the callModel function.
|
|
6834
6885
|
*/
|
|
6835
6886
|
const DELETE_MODEL_APP_FUNCTION_KEY = 'deleteModel';
|
|
6836
|
-
function onCallCreateModelResultWithDocs(result) {
|
|
6837
|
-
return onCallCreateModelResult(util.asArray(result).map(x => x.documentRef.path));
|
|
6838
|
-
}
|
|
6839
|
-
function onCallCreateModelResult(modelKeys) {
|
|
6840
|
-
return {
|
|
6841
|
-
modelKeys: util.asArray(modelKeys)
|
|
6842
|
-
};
|
|
6843
|
-
}
|
|
6844
6887
|
|
|
6845
6888
|
const MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_DEFAULT = '_';
|
|
6846
6889
|
const MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_SPLITTER = ',';
|
|
6890
|
+
/**
|
|
6891
|
+
* Creates a ModelFirebaseFunctionMapFactory for the input config that targets the "callModel" Firebase function.
|
|
6892
|
+
*
|
|
6893
|
+
* @param configMap
|
|
6894
|
+
* @param crudConfigMap
|
|
6895
|
+
* @returns
|
|
6896
|
+
*/
|
|
6897
|
+
function callModelFirebaseFunctionMapFactory(configMap, crudConfigMap) {
|
|
6898
|
+
const functionFactory = firebaseFunctionMapFactory(configMap);
|
|
6899
|
+
return functionsInstance => {
|
|
6900
|
+
const functionMap = functionFactory(functionsInstance);
|
|
6901
|
+
const _callFn = util.cachedGetter(() => functions.httpsCallable(functionsInstance, CALL_MODEL_APP_FUNCTION_KEY));
|
|
6902
|
+
function makeCallFunction(call, fn, modelType, specifier) {
|
|
6903
|
+
return mapHttpsCallable(fn(), {
|
|
6904
|
+
mapInput: data => onCallTypedModelParams(modelType, data, specifier, call)
|
|
6905
|
+
}, true);
|
|
6906
|
+
}
|
|
6907
|
+
function makeCallSpecifiers(call, fn, modelType, specifierKeys) {
|
|
6908
|
+
const modelTypeSuffix = util.capitalizeFirstLetter(modelType);
|
|
6909
|
+
const specifiers = {};
|
|
6910
|
+
specifierKeys.forEach(inputSpecifier => {
|
|
6911
|
+
const specifier = inputSpecifier === MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_DEFAULT ? '' : inputSpecifier;
|
|
6912
|
+
const specifierFn = makeCallFunction(call, fn, modelType, inputSpecifier);
|
|
6913
|
+
const fullSpecifierName = `${call}${modelTypeSuffix}${util.capitalizeFirstLetter(specifier)}`;
|
|
6914
|
+
specifiers[fullSpecifierName] = specifierFn;
|
|
6915
|
+
const shortSpecifierName = util.lowercaseFirstLetter(specifier) || call;
|
|
6916
|
+
specifiers[shortSpecifierName] = specifierFn;
|
|
6917
|
+
});
|
|
6918
|
+
return specifiers;
|
|
6919
|
+
}
|
|
6920
|
+
const result = util.build({
|
|
6921
|
+
base: functionMap,
|
|
6922
|
+
build: x => {
|
|
6923
|
+
Object.entries(crudConfigMap).forEach(([modelType, config]) => {
|
|
6924
|
+
const modelTypeSuffix = util.capitalizeFirstLetter(modelType);
|
|
6925
|
+
const {
|
|
6926
|
+
included: crudFunctionKeys,
|
|
6927
|
+
excluded: specifiedCallFunctionKeys
|
|
6928
|
+
} = util.separateValues(config, x => x.indexOf(':') === -1);
|
|
6929
|
+
const crudFunctions = new Set(crudFunctionKeys);
|
|
6930
|
+
const specifiedCallFunctionTuples = specifiedCallFunctionKeys.map(x => {
|
|
6931
|
+
const [crud, functionsSplit] = x.split(':', 2);
|
|
6932
|
+
const functions = functionsSplit.split(MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_SPLITTER);
|
|
6933
|
+
return [crud, functions];
|
|
6934
|
+
});
|
|
6935
|
+
// check that there isn't a repeat crud key configured, which disallowed configuration and would cause some functions to be ignored
|
|
6936
|
+
const encounteredCalls = new Set();
|
|
6937
|
+
function assertCallKeyNotEncountered(crud) {
|
|
6938
|
+
if (encounteredCalls.has(crud)) {
|
|
6939
|
+
throw new Error(`Cannot have multiple declarations of the same crud. Found repeat for crud: ${crud}`);
|
|
6940
|
+
} else {
|
|
6941
|
+
encounteredCalls.add(crud);
|
|
6942
|
+
}
|
|
6943
|
+
}
|
|
6944
|
+
crudFunctions.forEach(assertCallKeyNotEncountered);
|
|
6945
|
+
specifiedCallFunctionTuples.forEach(([crud]) => assertCallKeyNotEncountered(crud));
|
|
6946
|
+
// build and add the functions
|
|
6947
|
+
const specifierFunctions = new Map(specifiedCallFunctionTuples);
|
|
6948
|
+
function addCallFunctions(crud, fn, modelType) {
|
|
6949
|
+
let crudFns;
|
|
6950
|
+
if (crudFunctions.has(crud)) {
|
|
6951
|
+
crudFns = makeCallFunction(crud, fn, modelType);
|
|
6952
|
+
} else if (specifierFunctions.has(crud)) {
|
|
6953
|
+
crudFns = makeCallSpecifiers(crud, fn, modelType, specifierFunctions.get(crud));
|
|
6954
|
+
}
|
|
6955
|
+
if (crudFns) {
|
|
6956
|
+
modelTypeCalls[`${crud}${modelTypeSuffix}`] = crudFns;
|
|
6957
|
+
}
|
|
6958
|
+
}
|
|
6959
|
+
const modelTypeCalls = {};
|
|
6960
|
+
// add functions for each call type
|
|
6961
|
+
addCallFunctions('create', _callFn, modelType);
|
|
6962
|
+
addCallFunctions('read', _callFn, modelType);
|
|
6963
|
+
addCallFunctions('update', _callFn, modelType);
|
|
6964
|
+
addCallFunctions('delete', _callFn, modelType);
|
|
6965
|
+
// tslint:disable-next-line
|
|
6966
|
+
x[modelType] = modelTypeCalls;
|
|
6967
|
+
});
|
|
6968
|
+
}
|
|
6969
|
+
});
|
|
6970
|
+
return result;
|
|
6971
|
+
};
|
|
6972
|
+
}
|
|
6973
|
+
// MARK: Compat
|
|
6974
|
+
/**
|
|
6975
|
+
* @deprecated move to using callModelFirebaseFunctionMapFactory instead and the call configuration in general.
|
|
6976
|
+
*
|
|
6977
|
+
* This will be removed in the next release.
|
|
6978
|
+
*
|
|
6979
|
+
* @param configMap
|
|
6980
|
+
* @param crudConfigMap
|
|
6981
|
+
* @returns
|
|
6982
|
+
*/
|
|
6847
6983
|
function modelFirebaseFunctionMapFactory(configMap, crudConfigMap) {
|
|
6848
6984
|
const functionFactory = firebaseFunctionMapFactory(configMap);
|
|
6849
6985
|
return functionsInstance => {
|
|
@@ -7831,6 +7967,7 @@ exports.AbstractFirestoreDocument = AbstractFirestoreDocument;
|
|
|
7831
7967
|
exports.AbstractFirestoreDocumentDataAccessorWrapper = AbstractFirestoreDocumentDataAccessorWrapper;
|
|
7832
7968
|
exports.AbstractFirestoreDocumentWithParent = AbstractFirestoreDocumentWithParent;
|
|
7833
7969
|
exports.BASE_MODEL_STORAGE_FILE_PATH = BASE_MODEL_STORAGE_FILE_PATH;
|
|
7970
|
+
exports.CALL_MODEL_APP_FUNCTION_KEY = CALL_MODEL_APP_FUNCTION_KEY;
|
|
7834
7971
|
exports.COPY_USER_RELATED_DATA_ACCESSOR_FACTORY_FUNCTION = COPY_USER_RELATED_DATA_ACCESSOR_FACTORY_FUNCTION;
|
|
7835
7972
|
exports.CREATE_MODEL_APP_FUNCTION_KEY = CREATE_MODEL_APP_FUNCTION_KEY;
|
|
7836
7973
|
exports.ContextGrantedModelRolesReaderInstance = ContextGrantedModelRolesReaderInstance;
|
|
@@ -7919,6 +8056,7 @@ exports.assignUnitedStatesAddressFunction = assignUnitedStatesAddressFunction;
|
|
|
7919
8056
|
exports.assignWebsiteFileLinkFunction = assignWebsiteFileLinkFunction;
|
|
7920
8057
|
exports.assignWebsiteLinkFunction = assignWebsiteLinkFunction;
|
|
7921
8058
|
exports.buildFirebaseCollectionTypeModelTypeMap = buildFirebaseCollectionTypeModelTypeMap;
|
|
8059
|
+
exports.callModelFirebaseFunctionMapFactory = callModelFirebaseFunctionMapFactory;
|
|
7922
8060
|
exports.childFirestoreModelKey = childFirestoreModelKey;
|
|
7923
8061
|
exports.childFirestoreModelKeyPath = childFirestoreModelKeyPath;
|
|
7924
8062
|
exports.childFirestoreModelKeys = childFirestoreModelKeys;
|
|
@@ -8130,10 +8268,15 @@ exports.modifyBeforeSetInterceptAccessorFactoryFunction = modifyBeforeSetInterce
|
|
|
8130
8268
|
exports.newDocuments = newDocuments;
|
|
8131
8269
|
exports.noStringFormatInStorageUploadOptionsError = noStringFormatInStorageUploadOptionsError;
|
|
8132
8270
|
exports.offset = offset;
|
|
8271
|
+
exports.onCallCreateModelParams = onCallCreateModelParams;
|
|
8133
8272
|
exports.onCallCreateModelResult = onCallCreateModelResult;
|
|
8134
8273
|
exports.onCallCreateModelResultWithDocs = onCallCreateModelResultWithDocs;
|
|
8274
|
+
exports.onCallDeleteModelParams = onCallDeleteModelParams;
|
|
8135
8275
|
exports.onCallDevelopmentParams = onCallDevelopmentParams;
|
|
8276
|
+
exports.onCallReadModelParams = onCallReadModelParams;
|
|
8136
8277
|
exports.onCallTypedModelParams = onCallTypedModelParams;
|
|
8278
|
+
exports.onCallTypedModelParamsFunction = onCallTypedModelParamsFunction;
|
|
8279
|
+
exports.onCallUpdateModelParams = onCallUpdateModelParams;
|
|
8137
8280
|
exports.optionalFirestoreArray = optionalFirestoreArray;
|
|
8138
8281
|
exports.optionalFirestoreBoolean = optionalFirestoreBoolean;
|
|
8139
8282
|
exports.optionalFirestoreDate = optionalFirestoreDate;
|
package/index.esm.js
CHANGED
|
@@ -7556,44 +7556,95 @@ function lazyFirebaseFunctionsFactory(configMap) {
|
|
|
7556
7556
|
};
|
|
7557
7557
|
}
|
|
7558
7558
|
|
|
7559
|
+
/**
|
|
7560
|
+
* Set of known call types. The basic CRUD functions.
|
|
7561
|
+
*/
|
|
7562
|
+
|
|
7563
|
+
/**
|
|
7564
|
+
* A call function type specifier.
|
|
7565
|
+
*/
|
|
7566
|
+
|
|
7567
|
+
/**
|
|
7568
|
+
*
|
|
7569
|
+
*/
|
|
7570
|
+
|
|
7571
|
+
/**
|
|
7572
|
+
* Creates a OnCallTypedModelParamsFunction
|
|
7573
|
+
*
|
|
7574
|
+
* @param call
|
|
7575
|
+
* @returns
|
|
7576
|
+
*/
|
|
7577
|
+
function onCallTypedModelParamsFunction(call) {
|
|
7578
|
+
return (modelTypeInput, data, specifier) => {
|
|
7579
|
+
const modelType = typeof modelTypeInput === 'string' ? modelTypeInput : modelTypeInput.modelType;
|
|
7580
|
+
if (!modelType) {
|
|
7581
|
+
throw new Error('modelType is required.');
|
|
7582
|
+
}
|
|
7583
|
+
const result = {
|
|
7584
|
+
call,
|
|
7585
|
+
modelType,
|
|
7586
|
+
data
|
|
7587
|
+
};
|
|
7588
|
+
if (specifier != null) {
|
|
7589
|
+
result.specifier = specifier;
|
|
7590
|
+
}
|
|
7591
|
+
return result;
|
|
7592
|
+
};
|
|
7593
|
+
}
|
|
7594
|
+
|
|
7595
|
+
/**
|
|
7596
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'create'
|
|
7597
|
+
*/
|
|
7598
|
+
const onCallCreateModelParams = onCallTypedModelParamsFunction('create');
|
|
7599
|
+
|
|
7600
|
+
/**
|
|
7601
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'read'
|
|
7602
|
+
*/
|
|
7603
|
+
const onCallReadModelParams = onCallTypedModelParamsFunction('read');
|
|
7604
|
+
|
|
7605
|
+
/**
|
|
7606
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'update'
|
|
7607
|
+
*/
|
|
7608
|
+
const onCallUpdateModelParams = onCallTypedModelParamsFunction('update');
|
|
7609
|
+
|
|
7610
|
+
/**
|
|
7611
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'delete'
|
|
7612
|
+
*/
|
|
7613
|
+
const onCallDeleteModelParams = onCallTypedModelParamsFunction('delete');
|
|
7614
|
+
|
|
7559
7615
|
/**
|
|
7560
7616
|
* Creates a OnCallTypedModelParams
|
|
7561
7617
|
*
|
|
7618
|
+
* @deprecated use onCallTypedModelParamsFunction instead.
|
|
7619
|
+
*
|
|
7562
7620
|
* @param modelType
|
|
7563
7621
|
* @param data
|
|
7564
7622
|
* @returns
|
|
7565
7623
|
*/
|
|
7566
|
-
function onCallTypedModelParams(modelTypeInput, data, specifier) {
|
|
7567
|
-
|
|
7568
|
-
if (!modelType) {
|
|
7569
|
-
throw new Error('modelType is required.');
|
|
7570
|
-
}
|
|
7571
|
-
const result = {
|
|
7572
|
-
modelType,
|
|
7573
|
-
data
|
|
7574
|
-
};
|
|
7575
|
-
if (specifier != null) {
|
|
7576
|
-
result.specifier = specifier;
|
|
7577
|
-
}
|
|
7578
|
-
return result;
|
|
7624
|
+
function onCallTypedModelParams(modelTypeInput, data, specifier, call) {
|
|
7625
|
+
return onCallTypedModelParamsFunction(call)(modelTypeInput, data, specifier);
|
|
7579
7626
|
}
|
|
7580
7627
|
|
|
7581
7628
|
/**
|
|
7582
|
-
* Key used on the front-end and backend that refers to
|
|
7629
|
+
* Key used on the front-end and backend that refers to the call function.
|
|
7583
7630
|
*/
|
|
7584
|
-
const
|
|
7631
|
+
const CALL_MODEL_APP_FUNCTION_KEY = 'callModel';
|
|
7632
|
+
|
|
7585
7633
|
/**
|
|
7586
|
-
*
|
|
7634
|
+
* OnCallTypedModelParams for Create calls.
|
|
7587
7635
|
*/
|
|
7588
|
-
|
|
7636
|
+
|
|
7589
7637
|
/**
|
|
7590
|
-
*
|
|
7638
|
+
* OnCallTypedModelParams for Read calls.
|
|
7591
7639
|
*/
|
|
7592
|
-
|
|
7640
|
+
|
|
7593
7641
|
/**
|
|
7594
|
-
*
|
|
7642
|
+
* OnCallTypedModelParams for Update calls.
|
|
7643
|
+
*/
|
|
7644
|
+
|
|
7645
|
+
/**
|
|
7646
|
+
* OnCallTypedModelParams for Delete calls.
|
|
7595
7647
|
*/
|
|
7596
|
-
const DELETE_MODEL_APP_FUNCTION_KEY = 'deleteModel';
|
|
7597
7648
|
|
|
7598
7649
|
// MARK: Result
|
|
7599
7650
|
|
|
@@ -7606,6 +7657,35 @@ function onCallCreateModelResult(modelKeys) {
|
|
|
7606
7657
|
};
|
|
7607
7658
|
}
|
|
7608
7659
|
|
|
7660
|
+
// MARK: Compat
|
|
7661
|
+
/**
|
|
7662
|
+
* Key used on the front-end and backend that refers to a specific function for creating models.
|
|
7663
|
+
*
|
|
7664
|
+
* @deprecated Replaced by the callModel function.
|
|
7665
|
+
*/
|
|
7666
|
+
const CREATE_MODEL_APP_FUNCTION_KEY = 'createModel';
|
|
7667
|
+
|
|
7668
|
+
/**
|
|
7669
|
+
* Key used on the front-end and backend that refers to a specific function for reading models.
|
|
7670
|
+
*
|
|
7671
|
+
* @deprecated Replaced by the callModel function.
|
|
7672
|
+
*/
|
|
7673
|
+
const READ_MODEL_APP_FUNCTION_KEY = 'readModel';
|
|
7674
|
+
|
|
7675
|
+
/**
|
|
7676
|
+
* Key used on the front-end and backend that refers to a specific function for updating models.
|
|
7677
|
+
*
|
|
7678
|
+
* @deprecated Replaced by the callModel function.
|
|
7679
|
+
*/
|
|
7680
|
+
const UPDATE_MODEL_APP_FUNCTION_KEY = 'updateModel';
|
|
7681
|
+
|
|
7682
|
+
/**
|
|
7683
|
+
* Key used on the front-end and backend that refers to a specific function for deleting models.
|
|
7684
|
+
*
|
|
7685
|
+
* @deprecated Replaced by the callModel function.
|
|
7686
|
+
*/
|
|
7687
|
+
const DELETE_MODEL_APP_FUNCTION_KEY = 'deleteModel';
|
|
7688
|
+
|
|
7609
7689
|
/**
|
|
7610
7690
|
* Used to specify which function to direct requests to.
|
|
7611
7691
|
*/
|
|
@@ -7629,6 +7709,104 @@ const MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_SPLITTER = ',';
|
|
|
7629
7709
|
* Used for building a FirebaseFunctionMap<M> for a specific Functions instance.
|
|
7630
7710
|
*/
|
|
7631
7711
|
|
|
7712
|
+
/**
|
|
7713
|
+
* Creates a ModelFirebaseFunctionMapFactory for the input config that targets the "callModel" Firebase function.
|
|
7714
|
+
*
|
|
7715
|
+
* @param configMap
|
|
7716
|
+
* @param crudConfigMap
|
|
7717
|
+
* @returns
|
|
7718
|
+
*/
|
|
7719
|
+
function callModelFirebaseFunctionMapFactory(configMap, crudConfigMap) {
|
|
7720
|
+
const functionFactory = firebaseFunctionMapFactory(configMap);
|
|
7721
|
+
return functionsInstance => {
|
|
7722
|
+
const functionMap = functionFactory(functionsInstance);
|
|
7723
|
+
const _callFn = cachedGetter(() => httpsCallable(functionsInstance, CALL_MODEL_APP_FUNCTION_KEY));
|
|
7724
|
+
function makeCallFunction(call, fn, modelType, specifier) {
|
|
7725
|
+
return mapHttpsCallable(fn(), {
|
|
7726
|
+
mapInput: data => onCallTypedModelParams(modelType, data, specifier, call)
|
|
7727
|
+
}, true);
|
|
7728
|
+
}
|
|
7729
|
+
function makeCallSpecifiers(call, fn, modelType, specifierKeys) {
|
|
7730
|
+
const modelTypeSuffix = capitalizeFirstLetter(modelType);
|
|
7731
|
+
const specifiers = {};
|
|
7732
|
+
specifierKeys.forEach(inputSpecifier => {
|
|
7733
|
+
const specifier = inputSpecifier === MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_DEFAULT ? '' : inputSpecifier;
|
|
7734
|
+
const specifierFn = makeCallFunction(call, fn, modelType, inputSpecifier);
|
|
7735
|
+
const fullSpecifierName = `${call}${modelTypeSuffix}${capitalizeFirstLetter(specifier)}`;
|
|
7736
|
+
specifiers[fullSpecifierName] = specifierFn;
|
|
7737
|
+
const shortSpecifierName = lowercaseFirstLetter(specifier) || call;
|
|
7738
|
+
specifiers[shortSpecifierName] = specifierFn;
|
|
7739
|
+
});
|
|
7740
|
+
return specifiers;
|
|
7741
|
+
}
|
|
7742
|
+
const result = build({
|
|
7743
|
+
base: functionMap,
|
|
7744
|
+
build: x => {
|
|
7745
|
+
Object.entries(crudConfigMap).forEach(([modelType, config]) => {
|
|
7746
|
+
const modelTypeSuffix = capitalizeFirstLetter(modelType);
|
|
7747
|
+
const {
|
|
7748
|
+
included: crudFunctionKeys,
|
|
7749
|
+
excluded: specifiedCallFunctionKeys
|
|
7750
|
+
} = separateValues(config, x => x.indexOf(':') === -1);
|
|
7751
|
+
const crudFunctions = new Set(crudFunctionKeys);
|
|
7752
|
+
const specifiedCallFunctionTuples = specifiedCallFunctionKeys.map(x => {
|
|
7753
|
+
const [crud, functionsSplit] = x.split(':', 2);
|
|
7754
|
+
const functions = functionsSplit.split(MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_SPLITTER);
|
|
7755
|
+
return [crud, functions];
|
|
7756
|
+
});
|
|
7757
|
+
|
|
7758
|
+
// check that there isn't a repeat crud key configured, which disallowed configuration and would cause some functions to be ignored
|
|
7759
|
+
const encounteredCalls = new Set();
|
|
7760
|
+
function assertCallKeyNotEncountered(crud) {
|
|
7761
|
+
if (encounteredCalls.has(crud)) {
|
|
7762
|
+
throw new Error(`Cannot have multiple declarations of the same crud. Found repeat for crud: ${crud}`);
|
|
7763
|
+
} else {
|
|
7764
|
+
encounteredCalls.add(crud);
|
|
7765
|
+
}
|
|
7766
|
+
}
|
|
7767
|
+
crudFunctions.forEach(assertCallKeyNotEncountered);
|
|
7768
|
+
specifiedCallFunctionTuples.forEach(([crud]) => assertCallKeyNotEncountered(crud));
|
|
7769
|
+
|
|
7770
|
+
// build and add the functions
|
|
7771
|
+
const specifierFunctions = new Map(specifiedCallFunctionTuples);
|
|
7772
|
+
function addCallFunctions(crud, fn, modelType) {
|
|
7773
|
+
let crudFns;
|
|
7774
|
+
if (crudFunctions.has(crud)) {
|
|
7775
|
+
crudFns = makeCallFunction(crud, fn, modelType);
|
|
7776
|
+
} else if (specifierFunctions.has(crud)) {
|
|
7777
|
+
crudFns = makeCallSpecifiers(crud, fn, modelType, specifierFunctions.get(crud));
|
|
7778
|
+
}
|
|
7779
|
+
if (crudFns) {
|
|
7780
|
+
modelTypeCalls[`${crud}${modelTypeSuffix}`] = crudFns;
|
|
7781
|
+
}
|
|
7782
|
+
}
|
|
7783
|
+
const modelTypeCalls = {};
|
|
7784
|
+
|
|
7785
|
+
// add functions for each call type
|
|
7786
|
+
addCallFunctions('create', _callFn, modelType);
|
|
7787
|
+
addCallFunctions('read', _callFn, modelType);
|
|
7788
|
+
addCallFunctions('update', _callFn, modelType);
|
|
7789
|
+
addCallFunctions('delete', _callFn, modelType);
|
|
7790
|
+
|
|
7791
|
+
// tslint:disable-next-line
|
|
7792
|
+
x[modelType] = modelTypeCalls;
|
|
7793
|
+
});
|
|
7794
|
+
}
|
|
7795
|
+
});
|
|
7796
|
+
return result;
|
|
7797
|
+
};
|
|
7798
|
+
}
|
|
7799
|
+
|
|
7800
|
+
// MARK: Compat
|
|
7801
|
+
/**
|
|
7802
|
+
* @deprecated move to using callModelFirebaseFunctionMapFactory instead and the call configuration in general.
|
|
7803
|
+
*
|
|
7804
|
+
* This will be removed in the next release.
|
|
7805
|
+
*
|
|
7806
|
+
* @param configMap
|
|
7807
|
+
* @param crudConfigMap
|
|
7808
|
+
* @returns
|
|
7809
|
+
*/
|
|
7632
7810
|
function modelFirebaseFunctionMapFactory(configMap, crudConfigMap) {
|
|
7633
7811
|
const functionFactory = firebaseFunctionMapFactory(configMap);
|
|
7634
7812
|
return functionsInstance => {
|
|
@@ -8902,4 +9080,4 @@ function systemStateFirestoreCollection(firestoreContext, converters) {
|
|
|
8902
9080
|
});
|
|
8903
9081
|
}
|
|
8904
9082
|
|
|
8905
|
-
export { AbstractFirestoreDocument, AbstractFirestoreDocumentDataAccessorWrapper, AbstractFirestoreDocumentWithParent, BASE_MODEL_STORAGE_FILE_PATH, COPY_USER_RELATED_DATA_ACCESSOR_FACTORY_FUNCTION, CREATE_MODEL_APP_FUNCTION_KEY, ContextGrantedModelRolesReaderInstance, DEFAULT_DATE_CELL_RANGE_VALUE, DEFAULT_FIRESTORE_DATE_CELL_SCHEDULE_VALUE, DEFAULT_FIRESTORE_ITEM_PAGE_ITERATOR_ITEMS_PER_PAGE, DEFAULT_FIRESTORE_STRING_FIELD_VALUE, DEFAULT_FIRESTORE_UNITED_STATES_ADDRESS_VALUE, DEFAULT_FIRESTORE_WEBSITE_FILE_LINK_VALUE, DEFAULT_ITERATE_FIRESTORE_DOCUMENT_SNAPSHOT_BATCHES_BATCH_SIZE, DEFAULT_QUERY_CHANGE_WATCHER_DELAY, DEFAULT_SINGLE_ITEM_FIRESTORE_COLLECTION_DOCUMENT_IDENTIFIER, DEFAULT_WEBSITE_LINK, DELETE_MODEL_APP_FUNCTION_KEY, FIREBASE_AUTH_NETWORK_REQUEST_ERROR, FIREBASE_AUTH_NETWORK_REQUEST_FAILED, FIREBASE_AUTH_PASSWORD_MAX_LENGTH, FIREBASE_AUTH_PASSWORD_MIN_LENGTH, FIREBASE_AUTH_USER_NOT_FOUND_ERROR, FIREBASE_AUTH_WRONG_PASSWORD, FIREBASE_DEVELOPMENT_FUNCTIONS_MAP_KEY, FIREBASE_SERVER_AUTH_CLAIMS_RESET_LAST_COM_DATE_KEY, FIREBASE_SERVER_AUTH_CLAIMS_RESET_PASSWORD_KEY, FIREBASE_SERVER_AUTH_CLAIMS_SETUP_LAST_COM_DATE_KEY, FIREBASE_SERVER_AUTH_CLAIMS_SETUP_PASSWORD_KEY, FIRESTORE_CLIENT_QUERY_CONSTRAINT_HANDLER_MAPPING, FIRESTORE_COLLECTION_NAME_SEPARATOR, FIRESTORE_DUMMY_MODEL_KEY, FIRESTORE_EMPTY_VALUE, FIRESTORE_END_AT_QUERY_CONSTRAINT_TYPE, FIRESTORE_END_AT_VALUE_QUERY_CONSTRAINT_TYPE, FIRESTORE_END_BEFORE_QUERY_CONSTRAINT_TYPE, FIRESTORE_ITEM_PAGE_ITERATOR, FIRESTORE_ITEM_PAGE_ITERATOR_DELEGATE, FIRESTORE_LIMIT_QUERY_CONSTRAINT_TYPE, FIRESTORE_LIMIT_TO_LAST_QUERY_CONSTRAINT_TYPE, FIRESTORE_MAX_WHERE_IN_FILTER_ARGS_COUNT, FIRESTORE_MODEL_ID_REGEX, FIRESTORE_MODEL_KEY_REGEX, FIRESTORE_MODEL_KEY_REGEX_STRICT, FIRESTORE_OFFSET_QUERY_CONSTRAINT_TYPE, FIRESTORE_ORDER_BY_DOCUMENT_ID_QUERY_CONSTRAINT_TYPE, FIRESTORE_ORDER_BY_QUERY_CONSTRAINT_TYPE, FIRESTORE_PASSTHROUGH_FIELD, FIRESTORE_START_AFTER_QUERY_CONSTRAINT_TYPE, FIRESTORE_START_AT_QUERY_CONSTRAINT_TYPE, FIRESTORE_START_AT_VALUE_QUERY_CONSTRAINT_TYPE, FIRESTORE_WHERE_DOCUMENT_ID_QUERY_CONSTRAINT_TYPE, FIRESTORE_WHERE_QUERY_CONSTRAINT_TYPE, FirebaseDevelopmentFunctions, FirebaseModelPermissionServiceInstance, FirebaseServerError, FirestoreAccessorStreamMode, FirestoreDocumentContextType, FirestoreItemPageIterationInstance, InferredTargetModelIdParams, InferredTargetModelParams, IsFirestoreModelId, IsFirestoreModelKey, MAX_FIRESTORE_MAP_ZOOM_LEVEL_VALUE, MIN_FIRESTORE_MAP_ZOOM_LEVEL_VALUE, MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_DEFAULT, MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_SPLITTER, MODEL_STORAGE_FILE_SLASH_PATH_FACTORY, ModifyBeforeSetFirestoreDocumentDataAccessorWrapper, READ_MODEL_APP_FUNCTION_KEY, RUN_DEV_FUNCTION_APP_FUNCTION_KEY, SCHEDULED_FUNCTION_DEV_FUNCTION_SPECIFIER, ScheduledFunctionDevelopmentFirebaseFunctionListEntry, ScheduledFunctionDevelopmentFirebaseFunctionParams, ScheduledFunctionDevelopmentFunctionTypeEnum, SystemStateDocument, SystemStateFirestoreCollections, TargetModelIdParams, TargetModelParams, UPDATE_MODEL_APP_FUNCTION_KEY, addConstraintToBuilder, addOrReplaceLimitInConstraints, allChildDocumentsUnderParent, allChildDocumentsUnderParentPath, allChildDocumentsUnderRelativePath, asTopLevelFieldPath, asTopLevelFieldPaths, assertFirestoreUpdateHasData, assertStorageUploadOptionsStringFormat, assignDateCellRangeFunction, assignDateCellScheduleFunction, assignUnitedStatesAddressFunction, assignWebsiteFileLinkFunction, assignWebsiteLinkFunction, buildFirebaseCollectionTypeModelTypeMap, childFirestoreModelKey, childFirestoreModelKeyPath, childFirestoreModelKeys, clientFirebaseFirestoreContextFactory, clientFirebaseStorageContextFactory, contextGrantedModelRolesReader, contextGrantedModelRolesReaderDoesNotExistErrorMessage, contextGrantedModelRolesReaderPermissionErrorMessage, convertHttpsCallableErrorToReadableError, copyDocumentIdForUserRelatedModifierFunction, copyDocumentIdToFieldModifierFunction, copyUserRelatedDataAccessorFactoryFunction, copyUserRelatedDataModifierConfig, dataFromDocumentSnapshots, dataFromSnapshotStream, developmentFirebaseFunctionMapFactory, directDataHttpsCallable, documentData, documentDataFunction, documentDataWithIdAndKey, documentReferenceFromDocument, documentReferencesFromDocuments, documentReferencesFromSnapshot, endAt, endAtValue, endBefore, extendFirestoreCollectionWithSingleDocumentAccessor, filterConstraintsOfType, filterDisallowedFirestoreItemPageIteratorInputContraints, firebaseAuthErrorToReadableError, firebaseFirestoreClientDrivers, firebaseFirestoreQueryConstraintFunctionsDriver, firebaseFirestoreQueryDriver, firebaseFunctionMapFactory, firebaseModelLoader, firebaseModelPermissionService, firebaseModelService, firebaseModelServiceFactory, firebaseModelsService, firebaseQueryItemAccumulator, firebaseQuerySnapshotAccumulator, firebaseStorageBucketFolderPath, firebaseStorageClientAccessorDriver, firebaseStorageClientAccessorFile, firebaseStorageClientAccessorFolder, firebaseStorageClientDrivers, firebaseStorageClientListFilesResultFactory, firebaseStorageContextFactory, firebaseStorageFileExists, firebaseStorageFilePathFromStorageFilePath, firebaseStorageRefForStorageFilePath, firestoreArray, firestoreArrayMap, firestoreBitwiseObjectMap, firestoreBitwiseSet, firestoreBitwiseSetMap, firestoreBoolean, firestoreClientAccessorDriver, firestoreClientIncrementUpdateToUpdateData, firestoreContextFactory, firestoreDate, firestoreDateCellRange, firestoreDateCellRangeArray, firestoreDateCellRangeAssignFn, firestoreDateCellSchedule, firestoreDateCellScheduleAssignFn, firestoreDencoderArray, firestoreDencoderMap, firestoreDencoderStringArray, firestoreDocumentAccessorContextExtension, firestoreDocumentAccessorFactory, firestoreDocumentLoader, firestoreDummyKey, firestoreEncodedArray, firestoreEncodedObjectMap, firestoreEnum, firestoreEnumArray, firestoreField, firestoreFieldConfigToModelMapFunctionsRef, firestoreIdBatchVerifierFactory, firestoreIdentityTypeArray, firestoreIdentityTypeArrayName, firestoreItemPageIteration, firestoreItemPageIterationFactory, firestoreLatLngString, firestoreMap, firestoreMapZoomLevel, firestoreModelId, firestoreModelIdArrayField, firestoreModelIdFromDocument, firestoreModelIdGrantedRoleArrayMap, firestoreModelIdGrantedRoleMap, firestoreModelIdString, firestoreModelIdentity, firestoreModelIdentityTypeMap, firestoreModelIdsFromDocuments, firestoreModelIdsFromKey, firestoreModelKey, firestoreModelKeyArrayField, firestoreModelKeyCollectionName, firestoreModelKeyCollectionType, firestoreModelKeyCollectionTypeArray, firestoreModelKeyCollectionTypeArrayName, firestoreModelKeyCollectionTypePair, firestoreModelKeyEncodedGrantedRoleMap, firestoreModelKeyFromDocument, firestoreModelKeyGrantedRoleArrayMap, firestoreModelKeyGrantedRoleMap, firestoreModelKeyPairObject, firestoreModelKeyParentKey, firestoreModelKeyParentKeyPartPairs, firestoreModelKeyPart, firestoreModelKeyPartPairs, firestoreModelKeyPartPairsKeyPath, firestoreModelKeyPartPairsPaths, firestoreModelKeyPath, firestoreModelKeyString, firestoreModelKeyTypePair, firestoreModelKeys, firestoreModelKeysFromDocuments, firestoreModelType, firestoreNumber, firestoreObjectArray, firestorePassThroughField, firestoreQueryConstraint, firestoreQueryConstraintFactory, firestoreQueryFactory, firestoreSingleDocumentAccessor, firestoreString, firestoreSubObject, firestoreTimezoneString, firestoreUID, firestoreUniqueArray, firestoreUniqueKeyedArray, firestoreUniqueStringArray, firestoreUnitedStatesAddress, firestoreUnitedStatesAddressAssignFn, firestoreUpdateWithNoDataError, firestoreWebsiteFileLink, firestoreWebsiteFileLinkAssignFn, firestoreWebsiteFileLinkEncodedArray, firestoreWebsiteFileLinkObjectArray, firestoreWebsiteLink, firestoreWebsiteLinkArray, firestoreWebsiteLinkAssignFn, flatFirestoreModelKey, getDataFromDocumentSnapshots, getDocumentSnapshotData, getDocumentSnapshotDataPair, getDocumentSnapshotDataPairs, getDocumentSnapshotDataTuples, getDocumentSnapshotPair, getDocumentSnapshotPairs, getDocumentSnapshots, getDocumentSnapshotsData, grantFullAccessIfAdmin, grantFullAccessIfAuthUserRelated, grantModelRolesIfAdmin, grantModelRolesIfAdminFunction, grantModelRolesIfAuthUserRelatedModelFunction, grantModelRolesIfFunction, grantModelRolesIfHasAuthRolesFactory, grantModelRolesIfHasAuthRolesFunction, grantModelRolesOnlyIfFunction, inContextFirebaseModelServiceFactory, inContextFirebaseModelsServiceFactory, incrementUpdateWithAccessorFunction, inferKeyFromTwoWayFlatFirestoreModelKey, interceptAccessorFactoryFunction, isAdminInFirebaseModelContext, isFirebaseStorageObjectNotFoundError, isFirestoreModelId, isFirestoreModelKey, isOwnerOfUserRelatedModelInFirebaseModelContext, iterateFirestoreDocumentSnapshotBatches, iterateFirestoreDocumentSnapshotCheckpoints, iterateFirestoreDocumentSnapshotPairBatches, iterateFirestoreDocumentSnapshotPairs, iterateFirestoreDocumentSnapshots, iterationQueryDocChangeWatcher, iterationQueryDocChangeWatcherChangeTypeForGroup, latestDataFromDocuments, latestSnapshotsFromDocuments, lazyFirebaseFunctionsFactory, limit, limitToLast, limitedFirestoreDocumentAccessorFactory, loadDocumentsForDocumentReferences, loadDocumentsForDocumentReferencesFromValues, loadDocumentsForIds, loadDocumentsForIdsFromValues, loadDocumentsForKeys, loadDocumentsForKeysFromValues, loadDocumentsForSnapshots, loadDocumentsForValues, makeDocuments, makeFirestoreCollection, makeFirestoreCollectionGroup, makeFirestoreCollectionWithParent, makeFirestoreItemPageIteratorDelegate, makeFirestoreQueryConstraintFunctionsDriver, makeRootSingleItemFirestoreCollection, makeSingleItemFirestoreCollection, mapDataFromSnapshot, mapHttpsCallable, modelFirebaseFunctionMapFactory, modelStorageSlashPathFactory, modifyBeforeSetInterceptAccessorFactoryFunction, newDocuments, noStringFormatInStorageUploadOptionsError, offset, onCallCreateModelResult, onCallCreateModelResultWithDocs, onCallDevelopmentParams, onCallTypedModelParams, optionalFirestoreArray, optionalFirestoreBoolean, optionalFirestoreDate, optionalFirestoreEnum, optionalFirestoreField, optionalFirestoreNumber, optionalFirestoreString, optionalFirestoreUID, optionalFirestoreUnitedStatesAddress, orderBy, orderByDocumentId, readFirestoreModelKey, replaceConstraints, selectFromFirebaseModelsService, separateConstraints, setIdAndKeyFromKeyIdRefOnDocumentData, setIdAndKeyFromSnapshotOnDocumentData, snapshotConverterFunctions, snapshotStreamDataForAccessor, snapshotStreamForAccessor, startAfter, startAt, startAtValue, storageListFilesResultFactory, storageListFilesResultHasNoNextError, storagePathFactory, streamFromOnSnapshot, systemStateCollectionReference, systemStateConverter, systemStateFirestoreCollection, systemStateIdentity, twoWayFlatFirestoreModelKey, unsupportedFirestoreDriverFunctionError, updateWithAccessorUpdateAndConverterFunction, useContextAuth, useContextAuthUid, useDocumentSnapshot, useDocumentSnapshotData, useFirebaseModelsService, where, whereDateIsAfter, whereDateIsAfterWithSort, whereDateIsBefore, whereDateIsBeforeWithSort, whereDateIsBetween, whereDateIsInRange, whereDateIsOnOrAfter, whereDateIsOnOrAfterWithSort, whereDateIsOnOrBefore, whereDateIsOnOrBeforeWithSort, whereDocumentId, whereStringHasRootIdentityModelKey, whereStringValueHasPrefix };
|
|
9083
|
+
export { AbstractFirestoreDocument, AbstractFirestoreDocumentDataAccessorWrapper, AbstractFirestoreDocumentWithParent, BASE_MODEL_STORAGE_FILE_PATH, CALL_MODEL_APP_FUNCTION_KEY, COPY_USER_RELATED_DATA_ACCESSOR_FACTORY_FUNCTION, CREATE_MODEL_APP_FUNCTION_KEY, ContextGrantedModelRolesReaderInstance, DEFAULT_DATE_CELL_RANGE_VALUE, DEFAULT_FIRESTORE_DATE_CELL_SCHEDULE_VALUE, DEFAULT_FIRESTORE_ITEM_PAGE_ITERATOR_ITEMS_PER_PAGE, DEFAULT_FIRESTORE_STRING_FIELD_VALUE, DEFAULT_FIRESTORE_UNITED_STATES_ADDRESS_VALUE, DEFAULT_FIRESTORE_WEBSITE_FILE_LINK_VALUE, DEFAULT_ITERATE_FIRESTORE_DOCUMENT_SNAPSHOT_BATCHES_BATCH_SIZE, DEFAULT_QUERY_CHANGE_WATCHER_DELAY, DEFAULT_SINGLE_ITEM_FIRESTORE_COLLECTION_DOCUMENT_IDENTIFIER, DEFAULT_WEBSITE_LINK, DELETE_MODEL_APP_FUNCTION_KEY, FIREBASE_AUTH_NETWORK_REQUEST_ERROR, FIREBASE_AUTH_NETWORK_REQUEST_FAILED, FIREBASE_AUTH_PASSWORD_MAX_LENGTH, FIREBASE_AUTH_PASSWORD_MIN_LENGTH, FIREBASE_AUTH_USER_NOT_FOUND_ERROR, FIREBASE_AUTH_WRONG_PASSWORD, FIREBASE_DEVELOPMENT_FUNCTIONS_MAP_KEY, FIREBASE_SERVER_AUTH_CLAIMS_RESET_LAST_COM_DATE_KEY, FIREBASE_SERVER_AUTH_CLAIMS_RESET_PASSWORD_KEY, FIREBASE_SERVER_AUTH_CLAIMS_SETUP_LAST_COM_DATE_KEY, FIREBASE_SERVER_AUTH_CLAIMS_SETUP_PASSWORD_KEY, FIRESTORE_CLIENT_QUERY_CONSTRAINT_HANDLER_MAPPING, FIRESTORE_COLLECTION_NAME_SEPARATOR, FIRESTORE_DUMMY_MODEL_KEY, FIRESTORE_EMPTY_VALUE, FIRESTORE_END_AT_QUERY_CONSTRAINT_TYPE, FIRESTORE_END_AT_VALUE_QUERY_CONSTRAINT_TYPE, FIRESTORE_END_BEFORE_QUERY_CONSTRAINT_TYPE, FIRESTORE_ITEM_PAGE_ITERATOR, FIRESTORE_ITEM_PAGE_ITERATOR_DELEGATE, FIRESTORE_LIMIT_QUERY_CONSTRAINT_TYPE, FIRESTORE_LIMIT_TO_LAST_QUERY_CONSTRAINT_TYPE, FIRESTORE_MAX_WHERE_IN_FILTER_ARGS_COUNT, FIRESTORE_MODEL_ID_REGEX, FIRESTORE_MODEL_KEY_REGEX, FIRESTORE_MODEL_KEY_REGEX_STRICT, FIRESTORE_OFFSET_QUERY_CONSTRAINT_TYPE, FIRESTORE_ORDER_BY_DOCUMENT_ID_QUERY_CONSTRAINT_TYPE, FIRESTORE_ORDER_BY_QUERY_CONSTRAINT_TYPE, FIRESTORE_PASSTHROUGH_FIELD, FIRESTORE_START_AFTER_QUERY_CONSTRAINT_TYPE, FIRESTORE_START_AT_QUERY_CONSTRAINT_TYPE, FIRESTORE_START_AT_VALUE_QUERY_CONSTRAINT_TYPE, FIRESTORE_WHERE_DOCUMENT_ID_QUERY_CONSTRAINT_TYPE, FIRESTORE_WHERE_QUERY_CONSTRAINT_TYPE, FirebaseDevelopmentFunctions, FirebaseModelPermissionServiceInstance, FirebaseServerError, FirestoreAccessorStreamMode, FirestoreDocumentContextType, FirestoreItemPageIterationInstance, InferredTargetModelIdParams, InferredTargetModelParams, IsFirestoreModelId, IsFirestoreModelKey, MAX_FIRESTORE_MAP_ZOOM_LEVEL_VALUE, MIN_FIRESTORE_MAP_ZOOM_LEVEL_VALUE, MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_DEFAULT, MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_SPLITTER, MODEL_STORAGE_FILE_SLASH_PATH_FACTORY, ModifyBeforeSetFirestoreDocumentDataAccessorWrapper, READ_MODEL_APP_FUNCTION_KEY, RUN_DEV_FUNCTION_APP_FUNCTION_KEY, SCHEDULED_FUNCTION_DEV_FUNCTION_SPECIFIER, ScheduledFunctionDevelopmentFirebaseFunctionListEntry, ScheduledFunctionDevelopmentFirebaseFunctionParams, ScheduledFunctionDevelopmentFunctionTypeEnum, SystemStateDocument, SystemStateFirestoreCollections, TargetModelIdParams, TargetModelParams, UPDATE_MODEL_APP_FUNCTION_KEY, addConstraintToBuilder, addOrReplaceLimitInConstraints, allChildDocumentsUnderParent, allChildDocumentsUnderParentPath, allChildDocumentsUnderRelativePath, asTopLevelFieldPath, asTopLevelFieldPaths, assertFirestoreUpdateHasData, assertStorageUploadOptionsStringFormat, assignDateCellRangeFunction, assignDateCellScheduleFunction, assignUnitedStatesAddressFunction, assignWebsiteFileLinkFunction, assignWebsiteLinkFunction, buildFirebaseCollectionTypeModelTypeMap, callModelFirebaseFunctionMapFactory, childFirestoreModelKey, childFirestoreModelKeyPath, childFirestoreModelKeys, clientFirebaseFirestoreContextFactory, clientFirebaseStorageContextFactory, contextGrantedModelRolesReader, contextGrantedModelRolesReaderDoesNotExistErrorMessage, contextGrantedModelRolesReaderPermissionErrorMessage, convertHttpsCallableErrorToReadableError, copyDocumentIdForUserRelatedModifierFunction, copyDocumentIdToFieldModifierFunction, copyUserRelatedDataAccessorFactoryFunction, copyUserRelatedDataModifierConfig, dataFromDocumentSnapshots, dataFromSnapshotStream, developmentFirebaseFunctionMapFactory, directDataHttpsCallable, documentData, documentDataFunction, documentDataWithIdAndKey, documentReferenceFromDocument, documentReferencesFromDocuments, documentReferencesFromSnapshot, endAt, endAtValue, endBefore, extendFirestoreCollectionWithSingleDocumentAccessor, filterConstraintsOfType, filterDisallowedFirestoreItemPageIteratorInputContraints, firebaseAuthErrorToReadableError, firebaseFirestoreClientDrivers, firebaseFirestoreQueryConstraintFunctionsDriver, firebaseFirestoreQueryDriver, firebaseFunctionMapFactory, firebaseModelLoader, firebaseModelPermissionService, firebaseModelService, firebaseModelServiceFactory, firebaseModelsService, firebaseQueryItemAccumulator, firebaseQuerySnapshotAccumulator, firebaseStorageBucketFolderPath, firebaseStorageClientAccessorDriver, firebaseStorageClientAccessorFile, firebaseStorageClientAccessorFolder, firebaseStorageClientDrivers, firebaseStorageClientListFilesResultFactory, firebaseStorageContextFactory, firebaseStorageFileExists, firebaseStorageFilePathFromStorageFilePath, firebaseStorageRefForStorageFilePath, firestoreArray, firestoreArrayMap, firestoreBitwiseObjectMap, firestoreBitwiseSet, firestoreBitwiseSetMap, firestoreBoolean, firestoreClientAccessorDriver, firestoreClientIncrementUpdateToUpdateData, firestoreContextFactory, firestoreDate, firestoreDateCellRange, firestoreDateCellRangeArray, firestoreDateCellRangeAssignFn, firestoreDateCellSchedule, firestoreDateCellScheduleAssignFn, firestoreDencoderArray, firestoreDencoderMap, firestoreDencoderStringArray, firestoreDocumentAccessorContextExtension, firestoreDocumentAccessorFactory, firestoreDocumentLoader, firestoreDummyKey, firestoreEncodedArray, firestoreEncodedObjectMap, firestoreEnum, firestoreEnumArray, firestoreField, firestoreFieldConfigToModelMapFunctionsRef, firestoreIdBatchVerifierFactory, firestoreIdentityTypeArray, firestoreIdentityTypeArrayName, firestoreItemPageIteration, firestoreItemPageIterationFactory, firestoreLatLngString, firestoreMap, firestoreMapZoomLevel, firestoreModelId, firestoreModelIdArrayField, firestoreModelIdFromDocument, firestoreModelIdGrantedRoleArrayMap, firestoreModelIdGrantedRoleMap, firestoreModelIdString, firestoreModelIdentity, firestoreModelIdentityTypeMap, firestoreModelIdsFromDocuments, firestoreModelIdsFromKey, firestoreModelKey, firestoreModelKeyArrayField, firestoreModelKeyCollectionName, firestoreModelKeyCollectionType, firestoreModelKeyCollectionTypeArray, firestoreModelKeyCollectionTypeArrayName, firestoreModelKeyCollectionTypePair, firestoreModelKeyEncodedGrantedRoleMap, firestoreModelKeyFromDocument, firestoreModelKeyGrantedRoleArrayMap, firestoreModelKeyGrantedRoleMap, firestoreModelKeyPairObject, firestoreModelKeyParentKey, firestoreModelKeyParentKeyPartPairs, firestoreModelKeyPart, firestoreModelKeyPartPairs, firestoreModelKeyPartPairsKeyPath, firestoreModelKeyPartPairsPaths, firestoreModelKeyPath, firestoreModelKeyString, firestoreModelKeyTypePair, firestoreModelKeys, firestoreModelKeysFromDocuments, firestoreModelType, firestoreNumber, firestoreObjectArray, firestorePassThroughField, firestoreQueryConstraint, firestoreQueryConstraintFactory, firestoreQueryFactory, firestoreSingleDocumentAccessor, firestoreString, firestoreSubObject, firestoreTimezoneString, firestoreUID, firestoreUniqueArray, firestoreUniqueKeyedArray, firestoreUniqueStringArray, firestoreUnitedStatesAddress, firestoreUnitedStatesAddressAssignFn, firestoreUpdateWithNoDataError, firestoreWebsiteFileLink, firestoreWebsiteFileLinkAssignFn, firestoreWebsiteFileLinkEncodedArray, firestoreWebsiteFileLinkObjectArray, firestoreWebsiteLink, firestoreWebsiteLinkArray, firestoreWebsiteLinkAssignFn, flatFirestoreModelKey, getDataFromDocumentSnapshots, getDocumentSnapshotData, getDocumentSnapshotDataPair, getDocumentSnapshotDataPairs, getDocumentSnapshotDataTuples, getDocumentSnapshotPair, getDocumentSnapshotPairs, getDocumentSnapshots, getDocumentSnapshotsData, grantFullAccessIfAdmin, grantFullAccessIfAuthUserRelated, grantModelRolesIfAdmin, grantModelRolesIfAdminFunction, grantModelRolesIfAuthUserRelatedModelFunction, grantModelRolesIfFunction, grantModelRolesIfHasAuthRolesFactory, grantModelRolesIfHasAuthRolesFunction, grantModelRolesOnlyIfFunction, inContextFirebaseModelServiceFactory, inContextFirebaseModelsServiceFactory, incrementUpdateWithAccessorFunction, inferKeyFromTwoWayFlatFirestoreModelKey, interceptAccessorFactoryFunction, isAdminInFirebaseModelContext, isFirebaseStorageObjectNotFoundError, isFirestoreModelId, isFirestoreModelKey, isOwnerOfUserRelatedModelInFirebaseModelContext, iterateFirestoreDocumentSnapshotBatches, iterateFirestoreDocumentSnapshotCheckpoints, iterateFirestoreDocumentSnapshotPairBatches, iterateFirestoreDocumentSnapshotPairs, iterateFirestoreDocumentSnapshots, iterationQueryDocChangeWatcher, iterationQueryDocChangeWatcherChangeTypeForGroup, latestDataFromDocuments, latestSnapshotsFromDocuments, lazyFirebaseFunctionsFactory, limit, limitToLast, limitedFirestoreDocumentAccessorFactory, loadDocumentsForDocumentReferences, loadDocumentsForDocumentReferencesFromValues, loadDocumentsForIds, loadDocumentsForIdsFromValues, loadDocumentsForKeys, loadDocumentsForKeysFromValues, loadDocumentsForSnapshots, loadDocumentsForValues, makeDocuments, makeFirestoreCollection, makeFirestoreCollectionGroup, makeFirestoreCollectionWithParent, makeFirestoreItemPageIteratorDelegate, makeFirestoreQueryConstraintFunctionsDriver, makeRootSingleItemFirestoreCollection, makeSingleItemFirestoreCollection, mapDataFromSnapshot, mapHttpsCallable, modelFirebaseFunctionMapFactory, modelStorageSlashPathFactory, modifyBeforeSetInterceptAccessorFactoryFunction, newDocuments, noStringFormatInStorageUploadOptionsError, offset, onCallCreateModelParams, onCallCreateModelResult, onCallCreateModelResultWithDocs, onCallDeleteModelParams, onCallDevelopmentParams, onCallReadModelParams, onCallTypedModelParams, onCallTypedModelParamsFunction, onCallUpdateModelParams, optionalFirestoreArray, optionalFirestoreBoolean, optionalFirestoreDate, optionalFirestoreEnum, optionalFirestoreField, optionalFirestoreNumber, optionalFirestoreString, optionalFirestoreUID, optionalFirestoreUnitedStatesAddress, orderBy, orderByDocumentId, readFirestoreModelKey, replaceConstraints, selectFromFirebaseModelsService, separateConstraints, setIdAndKeyFromKeyIdRefOnDocumentData, setIdAndKeyFromSnapshotOnDocumentData, snapshotConverterFunctions, snapshotStreamDataForAccessor, snapshotStreamForAccessor, startAfter, startAt, startAtValue, storageListFilesResultFactory, storageListFilesResultHasNoNextError, storagePathFactory, streamFromOnSnapshot, systemStateCollectionReference, systemStateConverter, systemStateFirestoreCollection, systemStateIdentity, twoWayFlatFirestoreModelKey, unsupportedFirestoreDriverFunctionError, updateWithAccessorUpdateAndConverterFunction, useContextAuth, useContextAuthUid, useDocumentSnapshot, useDocumentSnapshotData, useFirebaseModelsService, where, whereDateIsAfter, whereDateIsAfterWithSort, whereDateIsBefore, whereDateIsBeforeWithSort, whereDateIsBetween, whereDateIsInRange, whereDateIsOnOrAfter, whereDateIsOnOrAfterWithSort, whereDateIsOnOrBefore, whereDateIsOnOrBeforeWithSort, whereDocumentId, whereStringHasRootIdentityModelKey, whereStringValueHasPrefix };
|
package/package.json
CHANGED
|
@@ -77,4 +77,21 @@ export type ModelFirebaseFunctionMap<M extends FirebaseFunctionTypeMap, C extend
|
|
|
77
77
|
* Used for building a FirebaseFunctionMap<M> for a specific Functions instance.
|
|
78
78
|
*/
|
|
79
79
|
export type ModelFirebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap, U extends ModelFirebaseCrudFunctionTypeMap> = (functionsInstance: Functions) => ModelFirebaseFunctionMap<M, U>;
|
|
80
|
+
/**
|
|
81
|
+
* Creates a ModelFirebaseFunctionMapFactory for the input config that targets the "callModel" Firebase function.
|
|
82
|
+
*
|
|
83
|
+
* @param configMap
|
|
84
|
+
* @param crudConfigMap
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
export declare function callModelFirebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap, U extends ModelFirebaseCrudFunctionTypeMap>(configMap: FirebaseFunctionTypeConfigMap<M>, crudConfigMap: ModelFirebaseCrudFunctionConfigMap<U, FirestoreModelIdentity>): ModelFirebaseFunctionMapFactory<M, U>;
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated move to using callModelFirebaseFunctionMapFactory instead and the call configuration in general.
|
|
90
|
+
*
|
|
91
|
+
* This will be removed in the next release.
|
|
92
|
+
*
|
|
93
|
+
* @param configMap
|
|
94
|
+
* @param crudConfigMap
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
80
97
|
export declare function modelFirebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap, U extends ModelFirebaseCrudFunctionTypeMap>(configMap: FirebaseFunctionTypeConfigMap<M>, crudConfigMap: ModelFirebaseCrudFunctionConfigMap<U, FirestoreModelIdentity>): ModelFirebaseFunctionMapFactory<M, U>;
|
|
@@ -1,37 +1,84 @@
|
|
|
1
1
|
import { type ArrayOrValue } from '@dereekb/util';
|
|
2
2
|
import { type DocumentReferenceRef } from '../firestore/reference';
|
|
3
3
|
import { type FirestoreModelKey, type FirestoreModelType, type FirestoreModelTypeRef } from '../firestore/collection/collection';
|
|
4
|
+
/**
|
|
5
|
+
* Set of known call types. The basic CRUD functions.
|
|
6
|
+
*/
|
|
7
|
+
export type KnownOnCallFunctionType = 'create' | 'read' | 'update' | 'delete';
|
|
8
|
+
/**
|
|
9
|
+
* A call function type specifier.
|
|
10
|
+
*/
|
|
11
|
+
export type OnCallFunctionType = KnownOnCallFunctionType | string;
|
|
4
12
|
export interface OnCallTypedModelParams<T = unknown> extends FirestoreModelTypeRef {
|
|
5
|
-
|
|
6
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Call type. Should typically be defined.
|
|
15
|
+
*/
|
|
16
|
+
readonly call?: OnCallFunctionType;
|
|
17
|
+
/**
|
|
18
|
+
* Call sub-function specifier.
|
|
19
|
+
*/
|
|
20
|
+
readonly specifier?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Call data
|
|
23
|
+
*/
|
|
24
|
+
readonly data: T;
|
|
7
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
export type OnCallTypeModelParamsFunction = <T>(modelTypeInput: FirestoreModelType | FirestoreModelTypeRef, data: T, specifier?: string) => OnCallTypedModelParams<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a OnCallTypedModelParamsFunction
|
|
32
|
+
*
|
|
33
|
+
* @param call
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
export declare function onCallTypedModelParamsFunction(call?: string): OnCallTypeModelParamsFunction;
|
|
37
|
+
/**
|
|
38
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'create'
|
|
39
|
+
*/
|
|
40
|
+
export declare const onCallCreateModelParams: OnCallTypeModelParamsFunction;
|
|
41
|
+
/**
|
|
42
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'read'
|
|
43
|
+
*/
|
|
44
|
+
export declare const onCallReadModelParams: OnCallTypeModelParamsFunction;
|
|
45
|
+
/**
|
|
46
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'update'
|
|
47
|
+
*/
|
|
48
|
+
export declare const onCallUpdateModelParams: OnCallTypeModelParamsFunction;
|
|
49
|
+
/**
|
|
50
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'delete'
|
|
51
|
+
*/
|
|
52
|
+
export declare const onCallDeleteModelParams: OnCallTypeModelParamsFunction;
|
|
8
53
|
/**
|
|
9
54
|
* Creates a OnCallTypedModelParams
|
|
10
55
|
*
|
|
56
|
+
* @deprecated use onCallTypedModelParamsFunction instead.
|
|
57
|
+
*
|
|
11
58
|
* @param modelType
|
|
12
59
|
* @param data
|
|
13
60
|
* @returns
|
|
14
61
|
*/
|
|
15
|
-
export declare function onCallTypedModelParams<T>(modelTypeInput: FirestoreModelType | FirestoreModelTypeRef, data: T, specifier?: string): OnCallTypedModelParams<T>;
|
|
62
|
+
export declare function onCallTypedModelParams<T>(modelTypeInput: FirestoreModelType | FirestoreModelTypeRef, data: T, specifier?: string, call?: string): OnCallTypedModelParams<T>;
|
|
16
63
|
/**
|
|
17
|
-
* Key used on the front-end and backend that refers to
|
|
64
|
+
* Key used on the front-end and backend that refers to the call function.
|
|
65
|
+
*/
|
|
66
|
+
export declare const CALL_MODEL_APP_FUNCTION_KEY = "callModel";
|
|
67
|
+
/**
|
|
68
|
+
* OnCallTypedModelParams for Create calls.
|
|
18
69
|
*/
|
|
19
|
-
export declare const CREATE_MODEL_APP_FUNCTION_KEY = "createModel";
|
|
20
70
|
export type OnCallCreateModelParams<T = unknown> = OnCallTypedModelParams<T>;
|
|
21
71
|
/**
|
|
22
|
-
*
|
|
72
|
+
* OnCallTypedModelParams for Read calls.
|
|
23
73
|
*/
|
|
24
|
-
export declare const READ_MODEL_APP_FUNCTION_KEY = "readModel";
|
|
25
74
|
export type OnCallReadModelParams<T = unknown> = OnCallTypedModelParams<T>;
|
|
26
75
|
/**
|
|
27
|
-
*
|
|
76
|
+
* OnCallTypedModelParams for Update calls.
|
|
28
77
|
*/
|
|
29
|
-
export declare const UPDATE_MODEL_APP_FUNCTION_KEY = "updateModel";
|
|
30
78
|
export type OnCallUpdateModelParams<T = unknown> = OnCallTypedModelParams<T>;
|
|
31
79
|
/**
|
|
32
|
-
*
|
|
80
|
+
* OnCallTypedModelParams for Delete calls.
|
|
33
81
|
*/
|
|
34
|
-
export declare const DELETE_MODEL_APP_FUNCTION_KEY = "deleteModel";
|
|
35
82
|
export type OnCallDeleteModelParams<T = unknown> = OnCallTypedModelParams<T>;
|
|
36
83
|
export interface OnCallCreateModelResult {
|
|
37
84
|
/**
|
|
@@ -41,3 +88,27 @@ export interface OnCallCreateModelResult {
|
|
|
41
88
|
}
|
|
42
89
|
export declare function onCallCreateModelResultWithDocs(result: ArrayOrValue<DocumentReferenceRef<unknown>>): OnCallCreateModelResult;
|
|
43
90
|
export declare function onCallCreateModelResult(modelKeys: ArrayOrValue<FirestoreModelKey>): OnCallCreateModelResult;
|
|
91
|
+
/**
|
|
92
|
+
* Key used on the front-end and backend that refers to a specific function for creating models.
|
|
93
|
+
*
|
|
94
|
+
* @deprecated Replaced by the callModel function.
|
|
95
|
+
*/
|
|
96
|
+
export declare const CREATE_MODEL_APP_FUNCTION_KEY = "createModel";
|
|
97
|
+
/**
|
|
98
|
+
* Key used on the front-end and backend that refers to a specific function for reading models.
|
|
99
|
+
*
|
|
100
|
+
* @deprecated Replaced by the callModel function.
|
|
101
|
+
*/
|
|
102
|
+
export declare const READ_MODEL_APP_FUNCTION_KEY = "readModel";
|
|
103
|
+
/**
|
|
104
|
+
* Key used on the front-end and backend that refers to a specific function for updating models.
|
|
105
|
+
*
|
|
106
|
+
* @deprecated Replaced by the callModel function.
|
|
107
|
+
*/
|
|
108
|
+
export declare const UPDATE_MODEL_APP_FUNCTION_KEY = "updateModel";
|
|
109
|
+
/**
|
|
110
|
+
* Key used on the front-end and backend that refers to a specific function for deleting models.
|
|
111
|
+
*
|
|
112
|
+
* @deprecated Replaced by the callModel function.
|
|
113
|
+
*/
|
|
114
|
+
export declare const DELETE_MODEL_APP_FUNCTION_KEY = "deleteModel";
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [10.0.19](https://github.com/dereekb/dbx-components/compare/v10.0.18-dev...v10.0.19) (2024-02-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [10.0.18](https://github.com/dereekb/dbx-components/compare/v10.0.17-dev...v10.0.18) (2024-02-13)
|
|
6
10
|
|
|
7
11
|
|